gcc 4.7.2
c89
apr utility 1.4
Hello,
I am using a thread pool to start threads. However, I can't see any apr function that allows me to wait for the threads to join.
The code sippet, removed all error checking and non-essential parts:
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);
}
I couldn't see any apr utity functions that join threads.
However, I did find this function apr_thread_join(apr_status_t *retval, apr_thread_t *thd)
However, it takes a apr_thread_t
as an argument.
The function timeout_duration takes a apr_thread_t
but how can I manage to pass it back, if I need to use it for joining?
Just a side note question. Is there any sample projects that use the apr and I can reference. The documentation is very limited.
Many thanks for any suggestions,