マルチスレッドのプログラミング

thr_pool_queue()

作業要求またはタスクをスレッドプールのジョブ待ち行列に入れます。

int  thr_pool_queue(thr_pool_t *pool, void *(*func)(void *), void *arg);
pool

thr_pool_create() から返されたスレッドプール識別子。

func

呼び出されるタスク関数。

arg

タスク関数に渡される唯一の引数。

エラーが発生した場合、thr_pool_queue() は、errno にエラーコードを設定して -1 を返します。

func 引数と arg 引数が、pthread_create の構文」に示されている pthread_create()start_routine 引数と arg 引数に似ていることに注意してください。thr_pool_queue() 関数は、既存のアプリケーション内の pthread_create() の置き換えとして使用できます。ただし、pthread_create() の代わりに thr_pool_queue() を使用する場合は、pthread_join() を使用してタスクの完了を待つことはできません。