On 25 September 2012 13:44, Paolo Bonzini <[email protected]> wrote:
> It makes sense to use it for other implementations than ucontext, too.
>  Coroutine *qemu_coroutine_create(CoroutineEntry *entry)
>  {
> -    Coroutine *co = qemu_coroutine_new();
> +    Coroutine *co;
> +
> +    co = QSLIST_FIRST(&pool);
> +    if (co) {
> +        QSLIST_REMOVE_HEAD(&pool, pool_next);
> +        pool_size--;
> +    } else {
> +        co = qemu_coroutine_new();
> +    }
>      co->entry = entry;
>      return co;
>  }

Since this is obviously going to blow up badly if it's called
from multiple threads, is there some kind of assert we can add
so that we fail obviously if somebody makes that coding error?
[the difficulty is probably when your backend is the gthread
one, at least I assume creating a coroutine inside a coroutine
is allowed.]

-- PMM

Reply via email to