Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Commit

Permalink
coroutine: add qemu_coroutine_entered() function
Browse files Browse the repository at this point in the history
See the doc comments for a description of this new coroutine API.

Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Fam Zheng <[email protected]>
Message-id: [email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
  • Loading branch information
stefanhaRH committed Sep 28, 2016
1 parent 844c822 commit f643e46
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/qemu/coroutine.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ Coroutine *coroutine_fn qemu_coroutine_self(void);
*/
bool qemu_in_coroutine(void);

/**
* Return true if the coroutine is currently entered
*
* A coroutine is "entered" if it has not yielded from the current
* qemu_coroutine_enter() call used to run it. This does not mean that the
* coroutine is currently executing code since it may have transferred control
* to another coroutine using qemu_coroutine_enter().
*
* When several coroutines enter each other there may be no way to know which
* ones have already been entered. In such situations this function can be
* used to avoid recursively entering coroutines.
*/
bool qemu_coroutine_entered(Coroutine *co);


/**
Expand Down
5 changes: 5 additions & 0 deletions util/qemu-coroutine.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,8 @@ void coroutine_fn qemu_coroutine_yield(void)
self->caller = NULL;
qemu_coroutine_switch(self, to, COROUTINE_YIELD);
}

bool qemu_coroutine_entered(Coroutine *co)
{
return co->caller;
}

0 comments on commit f643e46

Please sign in to comment.