From: sbrandt Date: Wed, 22 Jun 2005 04:44:26 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: v0.1~2049 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=057aaef5d4584ab25143885e9ae9bbc1b347c7e6;p=ceph.git *** empty log message *** git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@332 29311d96-e01e-0410-9327-a35deaab8ce9 --- diff --git a/ceph/common/Semaphore.h b/ceph/common/Semaphore.h new file mode 100644 index 0000000000000..f8821f7c686ae --- /dev/null +++ b/ceph/common/Semaphore.h @@ -0,0 +1,37 @@ +#ifndef _Sem_Posix_ +#define _Sem_Posix_ + +#include + +class Semaphore +{ + Mutex m; + Cond c; + int count; + + public: + + Semaphore() + { + count = 0; + } + + void Put() { + m.Lock(); + count++; + c.Signal(); + m.Unlock(); + } + + void Get() + { + m.Lock(); + while(count <= 0) { + C.Wait(m); + } + count--; + m.Unlock(); + } +}; + +#endif // !_Mutex_Posix_