Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef SYNCHRONIZED_H_
00024 #define SYNCHRONIZED_H_
00025
00026 #ifndef __XDISPATCH_INDIRECT__
00027 #error "Please #include <xdispatch/dispatch.h> instead of this file directly."
00028 #endif
00029
00030 __XDISPATCH_BEGIN_NAMESPACE
00031
00036 class XDISPATCH_EXPORT synclock;
00037
00044 XDISPATCH_EXPORT synclock get_lock_for_key(unsigned int key);
00045
00053 class XDISPATCH_EXPORT synclock {
00054
00055 public:
00056 synclock();
00057 synclock(const synclock&);
00058 ~synclock();
00059
00060 operator bool() const;
00061
00062 void unlock();
00063
00064 private:
00065 struct data;
00066 data* _d;
00067
00068 synclock& operator= (synclock);
00069
00070 friend XDISPATCH_EXPORT synclock get_lock_for_key(unsigned int);
00071 synclock(dispatch_semaphore_t);
00072 };
00073
00074 # define XDISPATCH_CONCAT(A,B) A ## B
00075 # define XDISPATCH_LOCK_VAR(X) XDISPATCH_CONCAT(xd_synclock_, X)
00076
00085 # define XDISPATCH_SYNCHRONIZE( lock ) for(xdispatch::synclock XDISPATCH_LOCK_VAR(__LINE__)(lock) ; XDISPATCH_LOCK_VAR(__LINE__) ; XDISPATCH_LOCK_VAR(__LINE__).unlock() )
00086
00095 # define XDISPATCH_SYNCHRONIZED XDISPATCH_SYNCHRONIZE(xdispatch::get_lock_for_key(__COUNTER__))
00096
00240 #ifndef XDISPATCH_NO_KEYWORDS
00241 # ifndef synchronize
00242 # define synchronize( lock ) XDISPATCH_SYNCHRONIZE(lock)
00243 # endif
00244
00245 # ifndef synchronized
00246 # define synchronized XDISPATCH_SYNCHRONIZED
00247 # endif
00248 #endif
00249
00250 __XDISPATCH_END_NAMESPACE
00251
00252 #endif