IBR-DTNSuite  0.8
ibrcommon/ibrcommon/thread/Semaphore.cpp
Go to the documentation of this file.
00001 #include "ibrcommon/config.h"
00002 #include "ibrcommon/thread/Semaphore.h"
00003 #include <iostream>
00004 
00005 using namespace std;
00006 
00007 namespace ibrcommon
00008 {
00009         Semaphore::Semaphore(unsigned int value)
00010         {
00011                 sem_init(&count_sem, 0, value);
00012         }
00013 
00014         Semaphore::~Semaphore()
00015         {
00016                 sem_destroy(&count_sem);
00017         }
00018 
00019         void Semaphore::wait()
00020         {
00021                 sem_wait(&count_sem);
00022         }
00023 
00024         void Semaphore::post()
00025         {
00026                 sem_post(&count_sem);
00027         }
00028 }