summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/thread.h
diff options
context:
space:
mode:
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);