Revision c4d9d196 thread-pool.c

b/thread-pool.c
78 78
    bool stopping;
79 79
};
80 80

  
81
/* Currently there is only one thread pool instance. */
82
static ThreadPool global_pool;
83

  
84 81
static void *worker_thread(void *opaque)
85 82
{
86 83
    ThreadPool *pool = opaque;
......
239 236
    .cancel             = thread_pool_cancel,
240 237
};
241 238

  
242
BlockDriverAIOCB *thread_pool_submit_aio(ThreadPoolFunc *func, void *arg,
239
BlockDriverAIOCB *thread_pool_submit_aio(ThreadPool *pool,
240
        ThreadPoolFunc *func, void *arg,
243 241
        BlockDriverCompletionFunc *cb, void *opaque)
244 242
{
245
    ThreadPool *pool = &global_pool;
246 243
    ThreadPoolElement *req;
247 244

  
248 245
    req = qemu_aio_get(&thread_pool_aiocb_info, NULL, cb, opaque);
......
278 275
    qemu_coroutine_enter(co->co, NULL);
279 276
}
280 277

  
281
int coroutine_fn thread_pool_submit_co(ThreadPoolFunc *func, void *arg)
278
int coroutine_fn thread_pool_submit_co(ThreadPool *pool, ThreadPoolFunc *func,
279
                                       void *arg)
282 280
{
283 281
    ThreadPoolCo tpc = { .co = qemu_coroutine_self(), .ret = -EINPROGRESS };
284 282
    assert(qemu_in_coroutine());
285
    thread_pool_submit_aio(func, arg, thread_pool_co_cb, &tpc);
283
    thread_pool_submit_aio(pool, func, arg, thread_pool_co_cb, &tpc);
286 284
    qemu_coroutine_yield();
287 285
    return tpc.ret;
288 286
}
289 287

  
290
void thread_pool_submit(ThreadPoolFunc *func, void *arg)
288
void thread_pool_submit(ThreadPool *pool, ThreadPoolFunc *func, void *arg)
291 289
{
292
    thread_pool_submit_aio(func, arg, NULL, NULL);
290
    thread_pool_submit_aio(pool, func, arg, NULL, NULL);
293 291
}
294 292

  
295 293
static void thread_pool_init_one(ThreadPool *pool, AioContext *ctx)
......
354 352
    event_notifier_cleanup(&pool->notifier);
355 353
    g_free(pool);
356 354
}
357

  
358
static void thread_pool_init(void)
359
{
360
    thread_pool_init_one(&global_pool, NULL);
361
}
362

  
363
block_init(thread_pool_init)

Also available in: Unified diff