apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cheng Po-wen <st...@itri.org.tw>
Subject some questions about thread creation and thread pool
Date Wed, 27 Apr 2005 12:09:29 GMT

I try to write a thread pool implementation on top of Apache APR,
I meet some problems:

1. apr_thread_create <group__apr__thread__proc.html#ga14> (apr_thread_t
<group__apr__thread__proc.html#ga2> **new_thread, ....., apr_pool_t
<group__apr__pools.html#ga0> *cont)

I've trace the source code about this function,
internally, it uses "count" to allocate the memory for apr_thread_t, &
like :

(*new) = (apr_thread_t *)apr_pcalloc(pool, sizeof(apr_thread_t));
(*new)->td = (pthread_t *)apr_pcalloc(pool, sizeof(pthread_t));

and it uses "count" as parent pool to create a new pool for this thread,

when "child threads" exit, they will automatically destroy their own pool,
but the questions is this will still leave the apr_thread_t, & pthread_t
memory allocated in the parent pool "dangling".

can I solve the "dangling" memory problem when creating Thread Pool on
top of APR?
because threads are created & exit (if nessary) all the time in my


Sting, Cheng Po-wen(鄭博文)
Phone :  886-3-5914545  Fax : 886-3-5820085
E-Mail : sting@itri.org.tw

Internet Software Technology Division(W100)
Computer & Communication Research Lab. / ITRI

View raw message