diff --git a/include/libcotask/task.h b/include/libcotask/task.h index 70fbea8..25e40e0 100755 --- a/include/libcotask/task.h +++ b/include/libcotask/task.h @@ -333,10 +333,10 @@ namespace cotask { * @note please not to make tasks refer to each other. [it will lead to memory leak] * @note [don't do that] ptr_t a = ..., b = ...; a.await(b); b.await(a); * @param wait_task which stack to wait for - * @note this task will loop wait for wait_task and ignore any remuse() call unless wait_task is changed. + * @note we will loop wait and ignore any resume(...) call * @return 0 or error code */ - inline int await(const ptr_t &wait_task) { + inline int await(ptr_t wait_task) { if (!wait_task) { return copp::COPP_EC_ARGS_ERROR; } @@ -364,10 +364,7 @@ namespace cotask { } int ret = 0; - self_t* origin_wait_task = wait_task.get(); - // the reference maybe reset or changed here - // if wait_task changed it shouldn't loop wait that any more - while (wait_task && origin_wait_task == wait_task.get() && !(wait_task->is_exiting() || wait_task->is_completed())) { + while (!(wait_task->is_exiting() || wait_task->is_completed())) { if (is_exiting()) { return copp::COPP_EC_TASK_IS_EXITING; }