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>2005-06-09 09:11:51 +0400
committerChristopher Faylor <me@cgf.cx>2005-06-09 09:11:51 +0400
commited364fa9fbf461ef2f1b17ba17f210dd1066f6b3 (patch)
treeb058e5fd170aa4685c383e35001c9251d5610dce /winsup/cygwin/thread.h
parenta63c42932ecf41c1141789282838407329524e2c (diff)
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.
Diffstat (limited to 'winsup/cygwin/thread.h')
-rw-r--r--winsup/cygwin/thread.h18
1 files changed, 13 insertions, 5 deletions
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 <security.h>
#include <errno.h>
+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);