Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-12-12 07:15:32 +0300
committerChristopher Faylor <me@cgf.cx>2003-12-12 07:15:32 +0300
commitc76d70d7c04797ab9c24ae134d602b78d201b052 (patch)
tree3f6a9cee5f9f8b91a60445bea53eab83f686bef8 /winsup/cygwin/thread.cc
parent97cb9b9de404248a3c117a2f391696732ce6e860 (diff)
* 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.
Diffstat (limited to 'winsup/cygwin/thread.cc')
-rw-r--r--winsup/cygwin/thread.cc25
1 files changed, 16 insertions, 9 deletions
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);