From 51eb2a8257916ad7d0b153a5d30608446472521f Mon Sep 17 00:00:00 2001 From: Kevin Tew Date: Fri, 12 Dec 2008 19:36:37 +0000 Subject: [PATCH] refactored code out to mzrt_proc_first_thread_init svn: r12818 --- src/mzscheme/src/mzrt.c | 9 +++++++++ src/mzscheme/src/mzrt.h | 1 + src/mzscheme/src/places.c | 10 +--------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/mzscheme/src/mzrt.c b/src/mzscheme/src/mzrt.c index 3e94f127f0..c92b6d75ae 100644 --- a/src/mzscheme/src/mzrt.c +++ b/src/mzscheme/src/mzrt.c @@ -176,6 +176,15 @@ unsigned int mz_proc_thread_id(mz_proc_thread* thread) { return (unsigned int) thread->threadid; } +mz_proc_thread* mzrt_proc_first_thread_init() { + /* initialize mz_proc_thread struct for first thread myself that wasn't created with mz_proc_thread_create, + * so it can communicate with other mz_proc_thread_created threads via pt_mboxes */ + mz_proc_thread *thread = (mz_proc_thread*)malloc(sizeof(mz_proc_thread)); + thread->mbox = pt_mbox_create(); + thread->threadid = mz_proc_thread_self(); + proc_thread_self = thread; + return thread; +} mz_proc_thread* mz_proc_thread_create(mz_proc_thread_start start_proc, void* data) { mz_proc_thread *thread = (mz_proc_thread*)malloc(sizeof(mz_proc_thread)); diff --git a/src/mzscheme/src/mzrt.h b/src/mzscheme/src/mzrt.h index 104845f225..f97ae6e579 100644 --- a/src/mzscheme/src/mzrt.h +++ b/src/mzscheme/src/mzrt.h @@ -39,6 +39,7 @@ typedef DWORD (WINAPI *mz_proc_thread_start)(void*); typedef void *(mz_proc_thread_start)(void*); #endif +mz_proc_thread* mzrt_proc_first_thread_init(); mz_proc_thread* mz_proc_thread_create(mz_proc_thread_start*, void* data); void *mz_proc_thread_wait(mz_proc_thread *thread); diff --git a/src/mzscheme/src/places.c b/src/mzscheme/src/places.c index e2d03b1c35..1350909fb2 100644 --- a/src/mzscheme/src/places.c +++ b/src/mzscheme/src/places.c @@ -280,15 +280,7 @@ static void *master_scheme_place(void *data) { } void spawn_master_scheme_place() { - mz_proc_thread *thread; - pt_mbox *mbox; - unsigned int threadid; - thread = (mz_proc_thread*)malloc(sizeof(mz_proc_thread)); - mbox = pt_mbox_create(); - threadid = mz_proc_thread_self(); - thread->threadid = threadid; - thread->mbox = mbox; - proc_thread_self = thread; + mzrt_proc_first_thread_init(); scheme_master_proc_thread = mz_proc_thread_create(master_scheme_place, NULL); }