Sem.cpp
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 //----------------------------------------------------------------------
00009 //----------------------------------------------------------------------
00010 #include "icl_core_thread/Sem.h"
00011 
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 thread {
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 is
00035   // really available. Otherwise create an ACE or POSIX
00036   // implementation, depending on the system configuration.
00037   // Remark: This allows us to compile programs with LXRT support but
00038   // run them on systems on which no LXRT is installed and to disable
00039   // LXRT support 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::tryWait()
00073 {
00074   return m_impl->tryWait();
00075 }
00076 
00077 bool Semaphore::wait()
00078 {
00079   return m_impl->wait();
00080 }
00081 
00082 bool Semaphore::wait(const icl_core::TimeSpan& timeout)
00083 {
00084   return m_impl->wait(timeout);
00085 }
00086 
00087 bool Semaphore::wait(const icl_core::TimeStamp& timeout)
00088 {
00089   return m_impl->wait(timeout);
00090 }
00091 
00093 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
00094 
00098 void Semaphore::Post()
00099 {
00100   post();
00101 }
00102 
00106 bool Semaphore::TryWait()
00107 {
00108   return tryWait();
00109 }
00110 
00114 bool Semaphore::Wait()
00115 {
00116   return wait();
00117 }
00118 
00122 bool Semaphore::Wait(const icl_core::TimeSpan& timeout)
00123 {
00124   return wait(timeout);
00125 }
00126 
00130 bool Semaphore::Wait(const icl_core::TimeStamp& timeout)
00131 {
00132   return wait(timeout);
00133 }
00134 
00135 #endif
00136 
00137 
00138 }
00139 }


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