From c76d70d7c04797ab9c24ae134d602b78d201b052 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Fri, 12 Dec 2003 04:15:32 +0000 Subject: * miscfuncs.cc (low_priority_sleep): Correct thinko which caused SetPriority to be called unnecessarily. * thread.cc (pthread::init_main_thread): Call new create_cancel_event function. (pthread::precreate): Ditto. (pthread::postcreate): Remove cancel_event creation. (pthread::create_cancel_event): Define new function. * thread.h (pthread::create_cancel_event): Declare new function. --- winsup/cygwin/thread.cc | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'winsup/cygwin/thread.cc') diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index a6b2f9919..b2ba543fe 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -233,6 +233,7 @@ pthread::init_mainthread () 0, FALSE, DUPLICATE_SAME_ACCESS)) thread->win32_obj_id = NULL; thread->set_tls_self_pointer (); + (void) thread->create_cancel_event (); thread->postcreate (); } @@ -282,6 +283,19 @@ pthread::~pthread () threads.remove (this); } +bool +pthread::create_cancel_event () +{ + cancel_event = ::CreateEvent (&sec_none_nih, TRUE, FALSE, NULL); + if (!cancel_event) + { + system_printf ("couldn't create cancel event for main thread, %E"); + /* we need the event for correct behaviour */ + return false; + } + return true; +} + void pthread::precreate (pthread_attr *newattr) { @@ -308,6 +322,8 @@ pthread::precreate (pthread_attr *newattr) } /* Change the mutex type to NORMAL to speed up mutex operations */ mutex.type = PTHREAD_MUTEX_NORMAL; + if (!create_cancel_event ()) + magic = 0; } void @@ -340,15 +356,6 @@ pthread::create (void *(*func) (void *), pthread_attr *newattr, void pthread::postcreate () { - cancel_event = ::CreateEvent (&sec_none_nih, TRUE, FALSE, NULL); - if (!cancel_event) - { - system_printf ("couldn't create cancel event for main thread, %E"); - /* we need the event for correct behaviour */ - magic = 0; - return; - } - valid = true; InterlockedIncrement (&MT_INTERFACE->threadcount); -- cgit v1.2.3