Cygwin: strptime: add release note
[newlib-cygwin.git] / winsup / cygwin / local_includes / sync.h
blobd0b48782d48b4c55fffb101ad39ff5727c9e929c
1 /* sync.h: Header file for cygwin synchronization primitives.
3 This file is part of Cygwin.
5 This software is a copyrighted work licensed under the terms of the
6 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
7 details. */
9 #pragma once
11 /* FIXME: Note that currently this class cannot be allocated via `new' since
12 there are issues with malloc and fork. */
13 class muto
15 public:
16 char *name;
17 private:
18 LONG sync; /* Used to serialize access to this class. */
19 LONG waiters; /* Number of threads waiting for lock. */
20 HANDLE bruteforce; /* event handle used to control waiting for lock. */
21 public:
22 LONG visits; /* Count of number of times a thread has called acquire. */
23 void *tls; /* Tls of lock owner. */
24 // class muto *next;
26 /* The real constructor. */
27 muto *init (const char *);
29 #if 0 /* FIXME: See comment in sync.cc */
30 ~muto ()
31 #endif
32 int acquire (DWORD ms = INFINITE); /* Acquire the lock. */
33 int release (_cygtls * = &_my_tls); /* Release the lock. */
35 bool acquired ();
36 void upforgrabs () {tls = this;} // just set to an invalid address
37 void grab ();
38 operator int () const {return !!name;}
41 class lock_process
43 bool skip_unlock;
44 static muto locker;
45 public:
46 static void init () {locker.init ("lock_process");}
47 void dont_bother () {skip_unlock = true;}
48 lock_process (bool exiting = false)
50 locker.acquire ();
51 skip_unlock = exiting;
53 void release ()
55 locker.release ();
56 skip_unlock = true;
58 ~lock_process ()
60 if (!skip_unlock)
61 release ();
63 operator LONG () const {return locker.visits; }
64 static void force_release (_cygtls *tid) {locker.release (tid);}
65 friend class dtable;
66 friend class fhandler_fifo;