Commit f643e469 authored by Stefan Hajnoczi's avatar Stefan Hajnoczi
Browse files

coroutine: add qemu_coroutine_entered() function



See the doc comments for a description of this new coroutine API.

Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: default avatarFam Zheng <famz@redhat.com>
Message-id: 1474989516-18255-2-git-send-email-stefanha@redhat.com
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
parent 844c8229
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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);


/**
+5 −0
Original line number Diff line number Diff line
@@ -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;
}