00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- 00002 //---------------------------------------------------------------------- 00008 //---------------------------------------------------------------------- 00009 #include "SemaphoreImplLxrt35.h" 00010 00011 #include <errno.h> 00012 00013 namespace icl_core { 00014 namespace logging { 00015 00016 SemaphoreImplLxrt35::SemaphoreImplLxrt35(size_t initial_value) 00017 : m_semaphore(NULL) 00018 { 00019 m_semaphore = new sem_t; 00020 sem_init_rt(m_semaphore, PTHREAD_PROCESS_PRIVATE, initial_value); 00021 } 00022 00023 SemaphoreImplLxrt35::~SemaphoreImplLxrt35() 00024 { 00025 if (m_semaphore == NULL) 00026 { 00027 // Nothing to be done here! 00028 } 00029 else 00030 { 00031 sem_destroy_rt(m_semaphore); 00032 delete m_semaphore; 00033 m_semaphore = NULL; 00034 } 00035 } 00036 00037 void SemaphoreImplLxrt35::post() 00038 { 00039 sem_post_rt(m_semaphore); 00040 } 00041 00042 bool SemaphoreImplLxrt35::wait() 00043 { 00044 int res = sem_wait_rt(m_semaphore); 00045 return (res == 0); 00046 } 00047 00048 } 00049 }