Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_CRITICALSECTION_H__
00009 #define __SP_CRITICALSECTION_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013
00014 #if defined(SP_PLATFORM_WINDOWS)
00015 # include <windows.h>
00016 #elif defined(SP_PLATFORM_LINUX) || defined(SP_PLATFORM_IOS)
00017 # include <pthread.h>
00018 #endif
00019
00020
00021 namespace sp
00022 {
00023
00024
00025 #define CRITICAL_SECTION(s, p) \
00026 s.lock(); \
00027 p \
00028 s.unlock();
00029
00030
00035 class SP_EXPORT CriticalSection
00036 {
00037
00038 public:
00039
00040 CriticalSection();
00041 ~CriticalSection();
00042
00043
00044
00049 void lock();
00050
00052 void unlock();
00053
00054 private:
00055
00056
00057
00058 #if defined(SP_PLATFORM_WINDOWS)
00059 mutable CRITICAL_SECTION Section_;
00060 #elif defined(SP_PLATFORM_LINUX) || defined(SP_PLATFORM_IOS)
00061 mutable pthread_mutex_t Section_;
00062 #endif
00063
00064 };
00065
00066
00067 }
00068
00069
00070 #endif
00071
00072
00073
00074