summaryrefslogtreecommitdiff
path: root/task.cc
diff options
context:
space:
mode:
Diffstat (limited to 'task.cc')
-rw-r--r--task.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/task.cc b/task.cc
index d539b50..10e9368 100644
--- a/task.cc
+++ b/task.cc
@@ -39,32 +39,38 @@ bool Task::ready()
{
for(const auto& task : dependsTasks)
{
- if(task->dirty() && !task->done())
+ if(task->dirty() || task->state() == State::Running)
{
return false;
}
}
+ task_state.store(State::Ready);
return true;
}
int Task::run()
{
- if(is_done.load())
+ if(task_state.load() == State::Done)
{
return 0;
}
+ task_state.store(State::Running);
auto ret = runInner();
if(ret == 0)
{
- is_done.store(true);
+ task_state.store(State::Done);
+ }
+ else
+ {
+ task_state.store(State::Error);
}
return ret;
}
-bool Task::done() const
+State Task::state() const
{
- return is_done.load();
+ return task_state.load();
}