Skip to content

Commit

Permalink
keep the same action by call await(task_ptr) and await(task*)
Browse files Browse the repository at this point in the history
  • Loading branch information
owent committed Jul 16, 2019
1 parent 93148df commit fa84edb
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions include/libcotask/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit fa84edb

Please sign in to comment.