Diff for /parser3/src/include/pa_threads.h between versions 1.1 and 1.32

version 1.1, 2001/01/29 11:17:49 version 1.32, 2015/10/26 01:21:56
Line 1 Line 1
 /*  /** @file
   $Id$          Parser: mutex & helpers decls.
   
           Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com)
           Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
 */  */
   
 #ifndef PA_THREADS_H  #ifndef PA_THREADS_H
 #define PA_THREADS_H  #define PA_THREADS_H
   
 #ifdef HAVE_CONFIG_H  #define IDENT_PA_THREADS_H "$Id$"
 #       include "pa_config.h"  
 #endif  
   
   #include "pa_config_includes.h"
 #include "pa_types.h"  #include "pa_types.h"
   
   /// thread ID type
   typedef unsigned int pa_thread_t;
   
   /// get caller thread ID
   pa_thread_t pa_get_thread_id();
   
 #ifdef MULTITHREAD  class AutoSYNCHRONIZED;
   
   /// simple semaphore object
 class Mutex {  class Mutex {
           friend class AutoSYNCHRONIZED;
   private:
         uint handle;          uint handle;
 public:  public:
         Mutex();          Mutex();
         ~Mutex();          ~Mutex();
         void lock();  private: // for AutoSYNCHRONIZED
         void unlock();          void acquire();
           void release();
 };  };
   
 #else  extern const bool parser_multithreaded;
   extern Mutex global_mutex;
   
 class Mutex {  /** 
         Mutex() {}          Helper to ensure paired Mutex::acquire() and Mutex::release().
         ~Mutex() {}  
         void lock() {}          Use it with SYNCHRONIZED macro
         void unlock() {}  */
   class AutoSYNCHRONIZED {
   public:
           AutoSYNCHRONIZED() { global_mutex.acquire(); }
           ~AutoSYNCHRONIZED() { global_mutex.release(); }
 };  };
   
 #endif  /** 
           put it to first line of a function to ensure thread safety.
           @verbatim
                   void someclass::somefunc(...) { SYNCHRONIZED;
                           ...
                   }
           @endverbatim
   
           WARNING: don't use THROW or PTHROW with such thread safety mechanizm -
           longjmp would leave global_mutex acquired, which is wrong!
   */
   #define SYNCHRONIZED AutoSYNCHRONIZED autoSYNCHRONIZED
   
 #endif  #endif

Removed from v.1.1  
changed lines
  Added in v.1.32


E-mail: