* 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.
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user