From ed364fa9fbf461ef2f1b17ba17f210dd1066f6b3 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 9 Jun 2005 05:11:51 +0000 Subject: Change pthread::cancelable_wait to just cancelable_wait, throughout. * thread.h (cw_sig_wait): New enum. (fast_mutex::lock): Use cancelable_wait with resumable signal. (cancelable_wait): Change fourth argument to cw_sig_wait enum. * thread.cc (cancelable_wait): Ditto. Loop on signal detection if fourth argument == cw_sig_resume. --- winsup/cygwin/thread.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'winsup/cygwin/thread.h') diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h index 8bd8b2557..6cce1fa4a 100644 --- a/winsup/cygwin/thread.h +++ b/winsup/cygwin/thread.h @@ -24,6 +24,13 @@ details. */ #include #include +enum cw_sig_wait +{ + cw_sig_nosig, + cw_sig_eintr, + cw_sig_resume +}; + extern "C" { void SetResourceLock (int, int, const char *) __attribute__ ((regparm (3))); @@ -31,6 +38,9 @@ void ReleaseResourceLock (int, int, const char *) __attribute__ ((regparm (3))); } +DWORD cancelable_wait (HANDLE, DWORD, const bool = true, const enum cw_sig_wait = cw_sig_nosig) + __attribute__ ((regparm (3))); + class fast_mutex { public: @@ -59,13 +69,13 @@ public: void lock () { - if (InterlockedIncrement ((long *)&lock_counter) != 1) - WaitForSingleObject (win32_obj_id, INFINITE); + if (InterlockedIncrement ((long *) &lock_counter) != 1) + cancelable_wait (win32_obj_id, INFINITE, false, cw_sig_resume); } void unlock () { - if (InterlockedDecrement ((long *)&lock_counter)) + if (InterlockedDecrement ((long *) &lock_counter)) ::ReleaseSemaphore (win32_obj_id, 1, NULL); } @@ -397,8 +407,6 @@ public: virtual void testcancel (); static void static_cancel_self (); - static DWORD cancelable_wait (HANDLE object, DWORD timeout, const bool do_cancel = true, const bool do_sig_wait = false); - virtual int setcancelstate (int state, int *oldstate); virtual int setcanceltype (int type, int *oldtype); -- cgit v1.2.3