Skip to content

Commit f643e46

Browse files
committed
coroutine: add qemu_coroutine_entered() function
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]>
1 parent 844c822 commit f643e46

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

include/qemu/coroutine.h

+13
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@ Coroutine *coroutine_fn qemu_coroutine_self(void);
9292
*/
9393
bool qemu_in_coroutine(void);
9494

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

96109

97110
/**

util/qemu-coroutine.c

+5
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,8 @@ void coroutine_fn qemu_coroutine_yield(void)
146146
self->caller = NULL;
147147
qemu_coroutine_switch(self, to, COROUTINE_YIELD);
148148
}
149+
150+
bool qemu_coroutine_entered(Coroutine *co)
151+
{
152+
return co->caller;
153+
}

0 commit comments

Comments
 (0)