gcc 4.7.2
c89
apr utility 1.4
こんにちは、
スレッドプールを使用してスレッドを開始しています。ただし、スレッドが参加するのを待つことができる apr 関数が表示されません。
コード sippet では、すべてのエラー チェックと重要でない部分が削除されています。
int main(void)
{
/* Initialize apr internal structures */
apr_initialize();
/* Create memory pool */
rv = apr_pool_create(&mem_pool, NULL);
/* Create thread pool */
memset(&buf, 0, sizeof buf);
rv = apr_thread_pool_create(&thd_pool,
init_threads,
max_threads,
mem_pool);
/* Process the number of jobs */
#define NUMBER_JOBS 1
for(i = 0; i < NUMBER_JOBS; i++) {
rv = apr_thread_pool_schedule(thd_pool,
timeout_duration,
(void*)channel,
(apr_interval_time_t)flash_timeout,
NULL);
}
/*
* Join all threads here
*/
/* Destroy resources */
apr_thread_pool_destroy(thd_pool);
apr_pool_destroy(mem_pool);
apr_terminate();
return 0;
error:
apr_thread_pool_destroy(thd_pool);
apr_pool_destroy(mem_pool);
apr_terminate();
return 1;
}
void* timeout_duration(apr_thread_t *thd, void *data)
{
channel_t *channel = (channel_t*)data;
LOG_DEBUG("Channel timeout notification [ %zu ]", channel->id);
}
スレッドを結合する apr utity 関数は見当たりませんでした。
ただし、この関数は見つかりましたが、引数としてapr_thread_join(apr_status_t *retval, apr_thread_t *thd)
aを取ります。apr_thread_t
関数 timeout_duration には時間がかかりますが、apr_thread_t
参加に使用する必要がある場合、どうすればそれを返すことができますか?
補足質問です。apr を使用するサンプル プロジェクトはありますか?参照できます。ドキュメントは非常に限られています。
ご提案いただきありがとうございます。