Semaphore.cpp
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 // This file is part of FZIs ic_workspace.
00005 //
00006 // This program is free software licensed under the LGPL
00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00008 // You can find a copy of this license in LICENSE folder in the top
00009 // directory of the source code.
00010 //
00011 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00012 //
00013 // -- END LICENSE BLOCK ------------------------------------------------
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   // Only create an LXRT implementation if the LXRT runtime system
00048   // is really available. Otherwise create an ACE or POSIX implementation,
00049   // depending on the system configuration.
00050   // Remark: This allows us to compile programs with LXRT support but run
00051   // them on systems on which no LXRT is installed and to disable LXRT support
00052   // at program startup on systems with installed LXRT!
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 }


fzi_icl_core
Author(s):
autogenerated on Thu Jun 6 2019 20:22:24