Semaphore.cpp
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 //----------------------------------------------------------------------
00009 //----------------------------------------------------------------------
00010 
00011 #include "Semaphore.h"
00012 
00013 #if defined _SYSTEM_LXRT_
00014 # include "SemaphoreImplLxrt.h"
00015 #endif
00016 
00017 #if defined _SYSTEM_DARWIN_
00018 # include "SemaphoreImplDarwin.h"
00019 #elif defined _SYSTEM_POSIX_
00020 # include "SemaphoreImplPosix.h"
00021 #elif defined _SYSTEM_WIN32_
00022 # include "SemaphoreImplWin32.h"
00023 #else
00024 # error "No semaphore implementation defined for this platform."
00025 #endif
00026 
00027 namespace icl_core {
00028 namespace logging {
00029 
00030 Semaphore::Semaphore(size_t initial_value)
00031   : m_impl(0)
00032 {
00033 #if defined _SYSTEM_LXRT_
00034   // Only create an LXRT implementation if the LXRT runtime system
00035   // is really available. Otherwise create an ACE or POSIX implementation,
00036   // depending on the system configuration.
00037   // Remark: This allows us to compile programs with LXRT support but run
00038   // them on systems on which no LXRT is installed and to disable LXRT support
00039   // at program startup on systems with installed LXRT!
00040   if (icl_core::os::isLxrtAvailable())
00041   {
00042     m_impl = new SemaphoreImplLxrt(initial_value);
00043   }
00044   else
00045   {
00046     m_impl = new SemaphoreImplPosix(initial_value);
00047   }
00048 
00049 #elif defined _SYSTEM_DARWIN_
00050   m_impl = new SemaphoreImplDarwin(initial_value);
00051 
00052 #elif defined _SYSTEM_POSIX_
00053   m_impl = new SemaphoreImplPosix(initial_value);
00054 
00055 #elif defined _SYSTEM_WIN32_
00056   m_impl = new SemaphoreImplWin32(initial_value);
00057 
00058 #endif
00059 }
00060 
00061 Semaphore::~Semaphore()
00062 {
00063   delete m_impl;
00064   m_impl = 0;
00065 }
00066 
00067 void Semaphore::post()
00068 {
00069   return m_impl->post();
00070 }
00071 
00072 bool Semaphore::wait()
00073 {
00074   return m_impl->wait();
00075 }
00076 
00078 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
00079 
00081   void Semaphore::Post()
00082   {
00083     post();
00084   }
00085 
00092   bool Semaphore::Wait()
00093   {
00094     return wait();
00095   }
00096 
00097 #endif
00098 
00099 
00100 }
00101 }


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Fri Aug 28 2015 12:59:19