From edb7d7fd5342b4519ddbdfe4b73a6503c1209908 Mon Sep 17 00:00:00 2001 From: Salikh Zakirov Date: Thu, 15 Mar 2007 20:05:38 +0300 Subject: [PATCH] Remove thread pool completely --- vm/thread/src/thread_native_basic.c | 27 +++++++++++++++------------ vm/thread/src/thread_private.h | 5 ----- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/vm/thread/src/thread_native_basic.c b/vm/thread/src/thread_native_basic.c index b3c54f3..1167330 100644 --- a/vm/thread/src/thread_native_basic.c +++ b/vm/thread/src/thread_native_basic.c @@ -112,7 +112,9 @@ IDATA VMCALL hythread_create_with_group(hythread_t *ret_thread, hythread_group_t new_thread->priority = priority ? priority : HYTHREAD_PRIORITY_NORMAL; //new_thread->suspend_request = suspend ? 1 : 0; - start_proc_data = (thread_start_proc_data *) apr_palloc(new_thread->pool, sizeof(thread_start_proc_data)); + start_proc_data = + (thread_start_proc_data *) malloc(sizeof(thread_start_proc_data)); + if (start_proc_data == NULL) { return TM_ERROR_OUT_OF_MEMORY; } @@ -606,22 +608,16 @@ static IDATA register_to_group(hythread_t thread, hythread_group_t group) { * @return created and initialized thread_t structure */ static hythread_t allocate_thread() { - apr_pool_t *pool; - apr_status_t apr_status; hythread_t ptr; IDATA status; - apr_status = apr_pool_create(&pool, TM_POOL); - if ((apr_status != APR_SUCCESS) || (pool == NULL)) return NULL; - - ptr = (hythread_t )apr_pcalloc(pool, sizeof(HyThread)); + ptr = (hythread_t )calloc(1, sizeof(HyThread)); if (ptr == NULL) return NULL; - ptr->pool = pool; ptr->os_handle = (osthread_t)NULL; ptr->priority = HYTHREAD_PRIORITY_NORMAL; // not implemented - //ptr->big_thread_local_storage = (void **)apr_pcalloc(pool, sizeof(void*)*tm_tls_capacity); + //ptr->big_thread_local_storage = (void **)calloc(1, sizeof(void*)*tm_tls_capacity); // Suspension ptr->suspend_request = 0; @@ -652,7 +648,7 @@ static void reset_thread(hythread_t thread) { thread->os_handle = (osthread_t)NULL; thread->priority = HYTHREAD_PRIORITY_NORMAL; // not implemented - //ptr->big_thread_local_storage = (void **)apr_pcalloc(pool, sizeof(void*)*tm_tls_capacity); + //ptr->big_thread_local_storage = (void **)calloc(1, sizeof(void*)*tm_tls_capacity); // Suspension thread->suspend_request = 0; @@ -675,13 +671,20 @@ static int VMAPICALL thread_start_proc(void *arg) { IDATA status; hythread_t thread; thread_start_proc_data * start_proc_data; + hythread_entrypoint_t start_proc; + hythread_group_t group; + void *data; start_proc_data = (thread_start_proc_data *) arg; thread = start_proc_data->thread; + start_proc = start_proc_data->start_proc; + data = start_proc_data->start_proc_args; + group = start_proc_data->group; + free(start_proc_data); TRACE(("TM: native thread started: native: %p tm: %p", apr_os_thread_current(), thread)); - status = register_to_group(thread, start_proc_data->group); + status = register_to_group(thread, group); if (status != TM_ERROR_NONE) { thread->exit_value = status; return thread->exit_value; @@ -693,7 +696,7 @@ static int VMAPICALL thread_start_proc(void *arg) { thread->state |= TM_THREAD_STATE_RUNNABLE; // Do actual call of the thread body supplied by the user. - start_proc_data->start_proc(start_proc_data->start_proc_args); + start_proc(data); // Shutdown sequence. status = hythread_global_lock(NULL); diff --git a/vm/thread/src/thread_private.h b/vm/thread/src/thread_private.h index 096a81e..2f9a160 100644 --- a/vm/thread/src/thread_private.h +++ b/vm/thread/src/thread_private.h @@ -280,11 +280,6 @@ typedef struct HyThread { IDATA thread_id; /** - * Memory pool in with this thread allocated - */ - apr_pool_t *pool; - - /** * APR thread attributes */ apr_threadattr_t *apr_attrs; -- 1.5.0.33.g1b20