提交 5ed5cb1e 编写于 作者: Z zhangchao19 提交者: fengqikai1414

cyber: croutine remove after the croutine execute completed

上级 cdb77c46
......@@ -83,6 +83,10 @@ void ChoreographyContext::RemoveCRoutine(uint64_t crid) {
auto cr = it->second;
if (cr->id() == crid) {
cr->Stop();
while (!cr->Acquire()) {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
AINFO_EVERY(1000) << "waiting for task " << cr->name() << " completion";
}
it = cr_queue_.erase(it);
cr->Release();
return;
......
......@@ -230,8 +230,12 @@ bool SchedulerChoreography::RemoveCRoutine(uint64_t crid) {
for (auto it = croutines.begin(); it != croutines.end(); ++it) {
if ((*it)->id() == crid) {
auto cr = *it;
cr->Stop();
while (!cr->Acquire()) {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
AINFO_EVERY(1000) << "waiting for task "
<< cr->name() << " completion";
}
croutines.erase(it);
cr->Release();
return true;
......
......@@ -226,8 +226,11 @@ bool SchedulerClassic::RemoveCRoutine(uint64_t crid) {
it != ClassicContext::cr_group_[group_name].at(prio).end(); ++it) {
if ((*it)->id() == crid) {
auto cr = *it;
(*it)->Stop();
cr->Stop();
while (!cr->Acquire()) {
std::this_thread::sleep_for(std::chrono::microseconds(1));
AINFO_EVERY(1000) << "waiting for task " << cr->name() << " completion";
}
it = ClassicContext::cr_group_[group_name].at(prio).erase(it);
cr->Release();
return true;
......
......@@ -62,10 +62,6 @@ void TaskManager::Shutdown() {
if (stop_.exchange(true)) {
return;
}
for (uint32_t i = 0; i < num_threads_; i++) {
scheduler::Instance()->RemoveTask(task_prefix + std::to_string(i));
}
}
} // namespace cyber
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册