SemaphoreImplPosix.cpp
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 //----------------------------------------------------------------------
00008 //----------------------------------------------------------------------
00009 #include "SemaphoreImplPosix.h"
00010 
00011 #include <errno.h>
00012 
00013 namespace icl_core {
00014 namespace logging {
00015 
00016 SemaphoreImplPosix::SemaphoreImplPosix(size_t initial_value)
00017   : m_semaphore(0)
00018 {
00019   m_semaphore = new sem_t;
00020   sem_init(m_semaphore, 0, initial_value);
00021 }
00022 
00023 SemaphoreImplPosix::~SemaphoreImplPosix()
00024 {
00025   if (m_semaphore)
00026   {
00027     sem_destroy(m_semaphore);
00028     delete m_semaphore;
00029     m_semaphore = 0;
00030   }
00031 }
00032 
00033 void SemaphoreImplPosix::post()
00034 {
00035   sem_post(m_semaphore);
00036 }
00037 
00038 bool SemaphoreImplPosix::wait()
00039 {
00040   int res = sem_wait(m_semaphore);
00041   return (res == 0);
00042 }
00043 
00044 }
00045 }


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