diff options
Diffstat (limited to 'winsup/cygwin/thread.h')
-rw-r--r-- | winsup/cygwin/thread.h | 74 |
1 files changed, 41 insertions, 33 deletions
diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h index 17f3b59cb..62bd1b959 100644 --- a/winsup/cygwin/thread.h +++ b/winsup/cygwin/thread.h @@ -267,52 +267,35 @@ public: class pthread_mutex: public verifyable_object { public: - static bool is_good_object (pthread_mutex_t const *); - static bool is_good_initializer (pthread_mutex_t const *); - static bool is_good_initializer_or_object (pthread_mutex_t const *); - static bool is_good_initializer_or_bad_object (pthread_mutex_t const *); - static bool can_be_unlocked (pthread_mutex_t const *); static void init_mutex (); static int init (pthread_mutex_t *, const pthread_mutexattr_t *attr, const pthread_mutex_t); - - unsigned long lock_counter; - HANDLE win32_obj_id; - unsigned int recursion_counter; - LONG condwaits; - pthread_t owner; -#ifdef DEBUGGING - DWORD tid; /* the thread id of the owner */ -#endif - int type; - int pshared; + static bool is_good_object (pthread_mutex_t const *); + static bool is_initializer (pthread_mutex_t const *); + static bool is_initializer_or_object (pthread_mutex_t const *); + static bool is_initializer_or_bad_object (pthread_mutex_t const *); int lock (); int trylock (); int unlock (); int destroy (); - void set_owner (pthread_t self) - { - recursion_counter = 1; - owner = self; -#ifdef DEBUGGING - tid = GetCurrentThreadId (); -#endif - } + void set_type (int in_type) {type = in_type;} int lock_recursive () { - if (UINT_MAX == recursion_counter) + if (recursion_counter == UINT_MAX) return EAGAIN; - ++recursion_counter; + recursion_counter++; return 0; } + bool can_be_unlocked (); + pthread_mutex (pthread_mutexattr * = NULL); pthread_mutex (pthread_mutex_t *, pthread_mutexattr *); ~pthread_mutex (); - class pthread_mutex * next; + class pthread_mutex *next; static void fixup_after_fork () { mutexes.fixup_after_fork (); @@ -320,10 +303,35 @@ public: } private: + unsigned long lock_counter; + HANDLE win32_obj_id; + unsigned int recursion_counter; + LONG condwaits; + pthread_t owner; +#ifdef DEBUGGING + DWORD tid; /* the thread id of the owner */ +#endif + int type; + int pshared; + + void set_owner (pthread_t self) + { + recursion_counter = 1; + owner = self; +#ifdef DEBUGGING + tid = GetCurrentThreadId (); +#endif + } + static const pthread_t _new_mutex; + static const pthread_t _unlocked_mutex; + static const pthread_t _destroyed_mutex; + + bool no_owner (); void _fixup_after_fork (); static List<pthread_mutex> mutexes; static fast_mutex mutex_initialization_lock; + friend class pthread_cond; }; #define WAIT_CANCELED (WAIT_OBJECT_0 + 1) @@ -467,9 +475,9 @@ class pthread_cond: public verifyable_object { public: static bool is_good_object (pthread_cond_t const *); - static bool is_good_initializer (pthread_cond_t const *); - static bool is_good_initializer_or_object (pthread_cond_t const *); - static bool is_good_initializer_or_bad_object (pthread_cond_t const *); + static bool is_initializer (pthread_cond_t const *); + static bool is_initializer_or_object (pthread_cond_t const *); + static bool is_initializer_or_bad_object (pthread_cond_t const *); static void init_mutex (); static int init (pthread_cond_t *, const pthread_condattr_t *); @@ -518,9 +526,9 @@ class pthread_rwlock: public verifyable_object { public: static bool is_good_object (pthread_rwlock_t const *); - static bool is_good_initializer (pthread_rwlock_t const *); - static bool is_good_initializer_or_object (pthread_rwlock_t const *); - static bool is_good_initializer_or_bad_object (pthread_rwlock_t const *); + static bool is_initializer (pthread_rwlock_t const *); + static bool is_initializer_or_object (pthread_rwlock_t const *); + static bool is_initializer_or_bad_object (pthread_rwlock_t const *); static void init_mutex (); static int init (pthread_rwlock_t *, const pthread_rwlockattr_t *); |