apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco Spinetti <m.spine...@pisa.iol.it>
Subject pool threads
Date Mon, 02 Apr 2007 13:21:51 GMT
Hi,
I have a question about how to use pool in threads.
I have a main which reads a file and fills an array with about 160000 
structs.
Then the mian starts NTHREADS threads with the main pool of main:

apr_thread_create(&tptr[i]->thread_tid, NULL, thread_main, 
(void*)context, context)

Each thread is an infinite loop:

..............

for ( ; ; ) {
        apr_pool_t *subpool;
       
        if (apr_pool_create(&subpool, context) != APR_SUCCESS) {
            return;
        }
        apr_pool_clear(subpool);
        apr_thread_mutex_lock(lock);
   
       <read_an_entry_of_array_and_elaborates_it>

       apr_thread_mutex_unlock(lock);
       
        apr_pool_destroy(subpool);
}

A the end the last thread does apr_thread_cond_signal(lock_cond) where 
the main is locked.
I'd like to know:

1) Is it the right way to use subpool for a multi-threading programme?
2) In the way I'm using threads after about 200 lines I have a 
segmentation fault. So I suppose that there is someting wrong: any advice?

Best regards

Marco



Mime
View raw message