mirror of https://github.com/milvus-io/milvus.git
MS-366 Implement TaskTable
Former-commit-id: e6d189c5c63b0477384353bf6f75482eeb196c7dpull/191/head
parent
404bc88b3f
commit
484f255f5e
|
@ -21,6 +21,7 @@ Please mark all change in change log and use the ticket from JIRA.
|
|||
- MS-361 - Add event in resource
|
||||
- MS-364 - Modify tasktableitem in tasktable
|
||||
- MS-365 - Use tasktableitemptr instead in event
|
||||
- MS-366 - Implement TaskTable
|
||||
|
||||
## New Feature
|
||||
- MS-343 - Implement ResourceMgr
|
||||
|
|
|
@ -12,18 +12,23 @@ namespace zilliz {
|
|||
namespace milvus {
|
||||
namespace engine {
|
||||
|
||||
TaskTable::TaskTable(std::vector<TaskPtr> &&tasks) {
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
TaskTable::Put(TaskPtr task) {
|
||||
|
||||
auto item = std::make_shared<TaskTableItem>();
|
||||
item->task = std::move(task);
|
||||
item->state = TaskTableItemState::LOADED;
|
||||
table_.push_back(item);
|
||||
}
|
||||
|
||||
void
|
||||
TaskTable::Put(std::vector<TaskPtr> &tasks) {
|
||||
|
||||
for (auto &task : tasks) {
|
||||
auto item = std::make_shared<TaskTableItem>();
|
||||
item->task = std::move(task);
|
||||
item->state = TaskTableItemState::LOADED;
|
||||
table_.push_back(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,26 +61,61 @@ TaskTable::Move(uint64_t index) {
|
|||
|
||||
bool
|
||||
TaskTable::Moved(uint64_t index) {
|
||||
auto &task = table_[index];
|
||||
|
||||
std::lock_guard<std::mutex> lock(task->mutex);
|
||||
if (task->state == TaskTableItemState::MOVING) {
|
||||
task->state = TaskTableItemState::MOVED;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
TaskTable::Load(uint64_t index) {
|
||||
auto &task = table_[index];
|
||||
|
||||
std::lock_guard<std::mutex> lock(task->mutex);
|
||||
if (task->state == TaskTableItemState::START) {
|
||||
task->state = TaskTableItemState::LOADING;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
TaskTable::Loaded(uint64_t index) {
|
||||
auto &task = table_[index];
|
||||
|
||||
std::lock_guard<std::mutex> lock(task->mutex);
|
||||
if (task->state == TaskTableItemState::LOADING) {
|
||||
task->state = TaskTableItemState::LOADED;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
TaskTable::Execute(uint64_t index) {
|
||||
auto &task = table_[index];
|
||||
|
||||
std::lock_guard<std::mutex> lock(task->mutex);
|
||||
if (task->state == TaskTableItemState::LOADED) {
|
||||
task->state = TaskTableItemState::EXECUTING;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
TaskTable::Executed(uint64_t index) {
|
||||
auto &task = table_[index];
|
||||
|
||||
std::lock_guard<std::mutex> lock(task->mutex);
|
||||
if (task->state == TaskTableItemState::EXECUTING) {
|
||||
task->state = TaskTableItemState::EXECUTED;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,9 +48,6 @@ class TaskTable {
|
|||
public:
|
||||
TaskTable() = default;
|
||||
|
||||
explicit
|
||||
TaskTable(std::vector<TaskPtr> &&tasks);
|
||||
|
||||
/*
|
||||
* Put one task;
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue