Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00022
00023
00024 #include "Semaphore.h"
00025
00026 #if defined _SYSTEM_LXRT_
00027 # include "SemaphoreImplLxrt.h"
00028 #endif
00029
00030 #if defined _SYSTEM_DARWIN_
00031 # include "SemaphoreImplDarwin.h"
00032 #elif defined _SYSTEM_POSIX_
00033 # include "SemaphoreImplPosix.h"
00034 #elif defined _SYSTEM_WIN32_
00035 # include "SemaphoreImplWin32.h"
00036 #else
00037 # error "No semaphore implementation defined for this platform."
00038 #endif
00039
00040 namespace icl_core {
00041 namespace logging {
00042
00043 Semaphore::Semaphore(size_t initial_value)
00044 : m_impl(0)
00045 {
00046 #if defined _SYSTEM_LXRT_
00047
00048
00049
00050
00051
00052
00053 if (icl_core::os::isLxrtAvailable())
00054 {
00055 m_impl = new SemaphoreImplLxrt(initial_value);
00056 }
00057 else
00058 {
00059 m_impl = new SemaphoreImplPosix(initial_value);
00060 }
00061
00062 #elif defined _SYSTEM_DARWIN_
00063 m_impl = new SemaphoreImplDarwin(initial_value);
00064
00065 #elif defined _SYSTEM_POSIX_
00066 m_impl = new SemaphoreImplPosix(initial_value);
00067
00068 #elif defined _SYSTEM_WIN32_
00069 m_impl = new SemaphoreImplWin32(initial_value);
00070
00071 #endif
00072 }
00073
00074 Semaphore::~Semaphore()
00075 {
00076 delete m_impl;
00077 m_impl = 0;
00078 }
00079
00080 void Semaphore::post()
00081 {
00082 return m_impl->post();
00083 }
00084
00085 bool Semaphore::wait()
00086 {
00087 return m_impl->wait();
00088 }
00089
00091 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
00092
00094 void Semaphore::Post()
00095 {
00096 post();
00097 }
00098
00105 bool Semaphore::Wait()
00106 {
00107 return wait();
00108 }
00109
00110 #endif
00111
00112
00113 }
00114 }