Project
Loading...
Searching...
No Matches
qsem.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#ifndef QSEM_H
16#define QSEM_H
17
18#ifdef _WIN32
20#else
21#include <semaphore.h>
22#endif
23
24class qSem
25{
26 public:
27 qSem(int32_t num = 1);
28 ~qSem();
29
30 int32_t Lock();
31 int32_t Unlock();
32 int32_t Trylock();
33 int32_t Query();
34
35 private:
36 int32_t max;
37 sem_t sem;
38};
39
41{
42 private:
43 qSem sem;
44
45 public:
46 qSignal() : sem(0) {}
47 void Wait() { sem.Lock(); }
48 void Signal() { sem.Unlock(); }
49};
50
51#endif
double num
Definition qsem.h:25
int32_t Trylock()
Definition qsem.cxx:57
int32_t Query()
Definition qsem.cxx:70
int32_t Unlock()
Definition qsem.cxx:48
~qSem()
Definition qsem.cxx:32
int32_t Lock()
Definition qsem.cxx:39
Definition qsem.h:41
qSignal()
Definition qsem.h:46
void Wait()
Definition qsem.h:47
void Signal()
Definition qsem.h:48