SemaphoreImplDarwin.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 <mach/mach_init.h>
00010 #include <mach/task.h>
00011 
00012 #include "SemaphoreImplDarwin.h"
00013 
00014 namespace icl_core {
00015 namespace logging {
00016 
00017 SemaphoreImplDarwin::SemaphoreImplDarwin(size_t initial_value)
00018   : m_semaphore(0)
00019 {
00020   semaphore_create(mach_task_self(), &m_semaphore, SYNC_POLICY_FIFO, initial_value);
00021 }
00022 
00023 SemaphoreImplDarwin::~SemaphoreImplDarwin()
00024 {
00025   semaphore_destroy(mach_task_self(), m_semaphore);
00026   m_semaphore = 0;
00027 }
00028 
00029 void SemaphoreImplDarwin::post()
00030 {
00031   semaphore_signal(m_semaphore);
00032 }
00033 
00034 bool SemaphoreImplDarwin::wait()
00035 {
00036   kern_return_t res = semaphore_wait(m_semaphore);
00037   return (res == KERN_SUCCESS);
00038 }
00039 
00040 }
00041 }


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