Skip to content

Commit

Permalink
Support running php and c coroutines at same time
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Dec 15, 2020
1 parent 027c6ca commit c94bfd8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/coroutine/base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Coroutine::BailoutCallback Coroutine::on_bailout = nullptr;
void Coroutine::yield() {
SW_ASSERT(current == this || on_bailout != nullptr);
state = STATE_WAITING;
if (sw_likely(on_yield)) {
if (sw_likely(on_yield && task)) {
on_yield(task);
}
current = origin;
Expand All @@ -46,7 +46,7 @@ void Coroutine::resume() {
return;
}
state = STATE_RUNNING;
if (sw_likely(on_resume)) {
if (sw_likely(on_resume && task)) {
on_resume(task);
}
origin = current;
Expand Down Expand Up @@ -77,7 +77,7 @@ void Coroutine::resume_naked() {
void Coroutine::close() {
SW_ASSERT(current == this);
state = STATE_END;
if (on_close) {
if (on_close && task) {
on_close(task);
}
#if !defined(SW_USE_THREAD_CONTEXT) && defined(SW_CONTEXT_DETECT_STACK_USAGE)
Expand Down

0 comments on commit c94bfd8

Please sign in to comment.