--- parser3/src/include/pa_threads.h 2001/09/26 10:32:25 1.17 +++ parser3/src/include/pa_threads.h 2020/12/15 11:28:40 1.36 @@ -1,25 +1,37 @@ /** @file Parser: mutex & helpers decls. - Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) - - $Id: pa_threads.h,v 1.17 2001/09/26 10:32:25 parser Exp $ + Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) + Author: Alexandr Petrosian (http://paf.design.ru) */ #ifndef PA_THREADS_H #define PA_THREADS_H +#define IDENT_PA_THREADS_H "$Id: pa_threads.h,v 1.36 2020/12/15 11:28:40 moko Exp $" + #include "pa_config_includes.h" #include "pa_types.h" +#ifdef _MSC_VER +#include +#endif + +/// get caller thread ID +uint pa_get_thread_id(); + class AutoSYNCHRONIZED; /// simple semaphore object class Mutex { - friend AutoSYNCHRONIZED; -private: - uint handle; + friend class AutoSYNCHRONIZED; + +#ifdef _MSC_VER +HANDLE handle; +#else +pthread_mutex_t handle; +#endif + public: Mutex(); ~Mutex(); @@ -32,9 +44,9 @@ extern Mutex global_mutex; /** Helper to ensure paired Mutex::acquire() and Mutex::release(). - Use it with SYNCHRONIZED macro */ + class AutoSYNCHRONIZED { public: AutoSYNCHRONIZED() { global_mutex.acquire(); }