Yu Kun e450df84e6 Merge remote-tracking branch 'upstream/branch-0.5.0' into branch-0.5.0-yk
Former-commit-id: a9efa9a72da2b4c178842ab06a610cf324855dae
2019-10-08 20:50:32 +08:00

96 lines
1.9 KiB
C++

// 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.
#pragma once
#include "Path.h"
#include "scheduler/job/Job.h"
#include "scheduler/tasklabel/TaskLabel.h"
#include "utils/Status.h"
#include <memory>
#include <string>
#include <utility>
namespace milvus {
namespace scheduler {
enum class LoadType {
DISK2CPU,
CPU2GPU,
GPU2CPU,
TEST,
};
enum class TaskType {
SearchTask,
DeleteTask,
BuildIndexTask,
TestTask,
};
class Task;
using TaskPtr = std::shared_ptr<Task>;
// TODO: re-design
class Task {
public:
explicit Task(TaskType type, TaskLabelPtr label) : type_(type), label_(std::move(label)) {
}
/*
* Just Getter;
*/
inline TaskType
Type() const {
return type_;
}
/*
* Transport path;
*/
inline Path&
path() {
return task_path_;
}
/*
* Getter and Setter;
*/
inline TaskLabelPtr&
label() {
return label_;
}
public:
virtual void
Load(LoadType type, uint8_t device_id) = 0;
virtual void
Execute() = 0;
public:
Path task_path_;
scheduler::JobWPtr job_;
TaskType type_;
TaskLabelPtr label_ = nullptr;
};
} // namespace scheduler
} // namespace milvus