PageRenderTime 81ms CodeModel.GetById 40ms app.highlight 2ms RepoModel.GetById 38ms app.codeStats 0ms

/mordor/semaphore.h

http://github.com/mozy/mordor
C Header | 45 lines | 34 code | 10 blank | 1 comment | 0 complexity | ef4d9d329166de08e2c64ce059e746cd MD5 | raw file
 1#ifndef __MORDOR_SEMAPHORE_H__
 2#define __MORDOR_SEMAPHORE_H__
 3// Copyright (c) 2009 - Mozy, Inc.
 4
 5#include "version.h"
 6
 7#include <boost/noncopyable.hpp>
 8
 9#ifdef WINDOWS
10#include <windows.h>
11#elif defined(OSX)
12#include <mach/semaphore.h>
13#elif defined(FREEBSD)
14#else
15#include <semaphore.h>
16#endif
17
18namespace Mordor {
19
20class Semaphore : boost::noncopyable
21{
22public:
23    Semaphore(unsigned int count = 0);
24    ~Semaphore();
25
26    void wait();
27
28    void notify();
29
30private:
31#ifdef WINDOWS
32    HANDLE m_semaphore;
33#elif defined(OSX)
34    task_t m_task;
35    semaphore_t m_semaphore;
36#elif defined(FREEBSD)
37    int m_semaphore;
38#else
39    sem_t m_semaphore;
40#endif
41};
42
43}
44
45#endif