SpecResLabel.h 1.5 KB
Newer Older
J
jinhai 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

W
wxyu 已提交
18 19 20
#pragma once

#include "TaskLabel.h"
21
#include "scheduler/ResourceMgr.h"
W
wxyu 已提交
22 23

#include <memory>
S
starlord 已提交
24
#include <string>
W
wxyu 已提交
25

S
starlord 已提交
26
// class Resource;
27
//
S
starlord 已提交
28
// using ResourceWPtr = std::weak_ptr<Resource>;
W
wxyu 已提交
29 30

namespace milvus {
W
wxyu 已提交
31
namespace scheduler {
W
wxyu 已提交
32 33

class SpecResLabel : public TaskLabel {
S
starlord 已提交
34
 public:
S
starlord 已提交
35
    explicit SpecResLabel(const ResourceWPtr& resource)
S
starlord 已提交
36 37
        : TaskLabel(TaskLabelType::SPECIFIED_RESOURCE), resource_(resource) {
    }
W
wxyu 已提交
38

S
starlord 已提交
39
    inline ResourceWPtr&
40
    resource() {
W
wxyu 已提交
41 42 43
        return resource_;
    }

S
starlord 已提交
44
    inline std::string&
45
    resource_name() {
W
wxyu 已提交
46 47 48
        return resource_name_;
    }

S
starlord 已提交
49
 private:
W
wxyu 已提交
50 51
    ResourceWPtr resource_;
    std::string resource_name_;
52
};
W
wxyu 已提交
53

54
using SpecResLabelPtr = std::shared_ptr<SpecResLabel>();
W
wxyu 已提交
55

S
starlord 已提交
56 57
}  // namespace scheduler
}  // namespace milvus