Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
semaphore.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013 sapier <sapier AT gmx DOT net>
4
5#pragma once
6
7#if defined(_WIN32)
8#include <windows.h>
9#elif defined(__MACH__) && defined(__APPLE__)
10#include <mach/semaphore.h>
11#else
12#include <semaphore.h>
13#endif
14
15#include "util/basic_macros.h"
16
18{
19public:
20 Semaphore(int val = 0);
21 ~Semaphore();
22
24
25 void post(unsigned int num = 1);
26 void wait();
27 bool wait(unsigned int time_ms);
28
29private:
30#if defined(WIN32)
31 HANDLE semaphore;
32#elif defined(__MACH__) && defined(__APPLE__)
33 semaphore_t semaphore;
34#else
35 sem_t semaphore;
36#endif
37};
Definition semaphore.h:18
void post(unsigned int num=1)
Definition semaphore.cpp:70
~Semaphore()
Definition semaphore.cpp:53
DISABLE_CLASS_COPY(Semaphore)
void wait()
Definition semaphore.cpp:85
Semaphore(int val=0)
Definition semaphore.cpp:41
sem_t semaphore
Definition semaphore.h:35