pthread_semaphore.hpp

00001 #line 1019 "./lpsrc/flx_pthread.pak"
00002 #ifndef __FLX_PTHREAD_SEMAPHORE_H__
00003 #define __FLX_PTHREAD_SEMAPHORE_H__
00004 #include <flx_pthread_config.hpp>
00005 #include "pthread_mutex.hpp"
00006 
00007 #include "pthread_win_posix_condv_emul.hpp"
00008 
00009 namespace flx { namespace pthread {
00010 
00011 // ********************************************************
00012 /// Semaphore
00013 // ********************************************************
00014 class PTHREAD_EXTERN flx_semaphore_t {
00015   sem_t sem;
00016 public:
00017   flx_semaphore_t(int n=0);
00018   ~flx_semaphore_t();
00019   void post();
00020   void operator++() { post(); }
00021   void wait();
00022   void operator--() { wait(); }
00023   int get();
00024   int operator*() { return get(); }
00025 
00026   /// atomic test and decrement if non-zero function.
00027   /// returns EAGAIN on failure to decrement.
00028   int trywait();
00029 };
00030 
00031 }} // namespace pthread, flx
00032 #endif
00033 

Generated on Thu May 29 13:50:31 2008 for Felix by  doxygen 1.5.5