LMMS
Loading...
Searching...
No Matches
LmmsSemaphore.h
Go to the documentation of this file.
1/*
2 * Semaphore.h - Semaphore declaration
3 *
4 * Copyright (c) 2022-2022 Johannes Lorenz <jlsf2013$users.sourceforge.net, $=@>
5 *
6 * This file is part of LMMS - https://lmms.io
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
22 *
23 */
24
25/*
26 * This code has been copied and adapted from https://github.com/drobilla/jalv
27 * File src/zix/sem.h
28 */
29
30#ifndef LMMS_SEMAPHORE_H
31#define LMMS_SEMAPHORE_H
32
33#include "lmmsconfig.h"
34
35#ifdef LMMS_BUILD_APPLE
36# include <mach/mach.h>
37#elif defined(LMMS_BUILD_WIN32)
38# include <windows.h>
39#else
40# include <semaphore.h>
41#endif
42
43
44namespace lmms {
45
67{
68public:
69 Semaphore(unsigned initial);
70 Semaphore(const Semaphore&) = delete;
71 Semaphore& operator=(const Semaphore&) = delete;
72 Semaphore(Semaphore&&) = delete;
74 ~Semaphore();
75
76 void post();
77 void wait();
78 bool tryWait();
79
80private:
81#ifdef LMMS_BUILD_APPLE
82 semaphore_t m_sem;
83#elif defined(LMMS_BUILD_WIN32)
85#else
86 sem_t m_sem;
87#endif
88};
89
90} // namespace lmms
91
92#endif // LMMS_SEMAPHORE_H
Semaphore(Semaphore &&)=delete
~Semaphore()
Definition LmmsSemaphore.cpp:115
Semaphore(const Semaphore &)=delete
Semaphore & operator=(const Semaphore &)=delete
Semaphore(unsigned initial)
Definition LmmsSemaphore.cpp:108
sem_t m_sem
Definition LmmsSemaphore.h:86
void wait()
Definition LmmsSemaphore.cpp:125
bool tryWait()
Definition LmmsSemaphore.cpp:135
void post()
Definition LmmsSemaphore.cpp:120
Semaphore & operator=(Semaphore &&)=delete
Definition AudioAlsa.cpp:35
void * HANDLE
Definition swell-types.h:212