[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] coroutine: always use pooling
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH] coroutine: always use pooling |
Date: |
Wed, 26 Sep 2012 15:34:57 +0100 |
On 25 September 2012 13:44, Paolo Bonzini <address@hidden> 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