libUTL++
Semaphore.h
1
#pragma once
2
4
5
#include <libutl/host_thread.h>
6
#include <libutl/NamedObjectMI.h>
7
9
10
UTL_NS_BEGIN;
11
13
21
23
class
Semaphore
:
public
Object
,
public
NamedObjectMI
24
{
25
UTL_CLASS_DECL
(
Semaphore
,
Object
);
26
UTL_CLASS_NO_COPY
;
27
28
public
:
33
Semaphore
(
uint_t
count
)
34
{
35
init
(count);
36
}
37
42
bool
trydown();
43
45
void
down();
46
48
void
up();
49
51
void
52
tryP
()
53
{
54
trydown();
55
}
56
58
void
59
P
()
60
{
61
down();
62
}
63
65
void
66
V
()
67
{
68
up();
69
}
70
71
private
:
72
void
init
(
uint_t
count
= 1);
73
void
deInit
();
74
75
private
:
76
#if UTL_HOST_OS == UTL_OS_MINGW
77
HANDLE _sem;
78
#else
79
sem_t _sem;
80
#endif
81
};
82
84
85
UTL_NS_END;
utl::Semaphore::V
void V()
Alias for up().
Definition:
Semaphore.h:66
utl::NamedObjectMI
Named object mix-in.
Definition:
NamedObjectMI.h:24
utl::deInit
void deInit()
De-initialize UTL++.
utl::Semaphore
Counter for resources shared between threads.
Definition:
Semaphore.h:23
UTL_CLASS_DECL
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
Definition:
macros.h:688
utl::Semaphore::P
void P()
Alias for down().
Definition:
Semaphore.h:59
utl::Semaphore::Semaphore
Semaphore(uint_t count)
Constructor.
Definition:
Semaphore.h:33
utl::uint_t
unsigned int uint_t
Unsigned integer.
Definition:
types.h:59
UTL_CLASS_NO_COPY
#define UTL_CLASS_NO_COPY
Declare that a class cannot do copy().
Definition:
macros.h:358
utl::Object
Root of UTL++ class hierarchy.
Definition:
Object.h:52
utl::Semaphore::tryP
void tryP()
Alias for trydown().
Definition:
Semaphore.h:52
utl::init
void init()
Initialize UTL++.
utl::count
size_t count(const FwdIt &begin, const FwdIt &end, const Predicate *pred=nullptr, bool predVal=true)
Count objects that satisfy a Predicate.
uts
Semaphore.h
Generated on Tue Feb 7 2017 20:11:33 for libUTL++ by
1.8.13