Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
icl_core
src
icl_core_logging
Semaphore.cpp
Go to the documentation of this file.
1
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2
3
// -- BEGIN LICENSE BLOCK ----------------------------------------------
4
// This file is part of FZIs ic_workspace.
5
//
6
// This program is free software licensed under the LGPL
7
// (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8
// You can find a copy of this license in LICENSE folder in the top
9
// directory of the source code.
10
//
11
// © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12
//
13
// -- END LICENSE BLOCK ------------------------------------------------
14
15
//----------------------------------------------------------------------
22
//----------------------------------------------------------------------
23
24
#include "
Semaphore.h
"
25
26
#if defined _SYSTEM_LXRT_
27
# include "SemaphoreImplLxrt.h"
28
#endif
29
30
#if defined _SYSTEM_DARWIN_
31
# include "SemaphoreImplDarwin.h"
32
#elif defined _SYSTEM_POSIX_
33
# include "SemaphoreImplPosix.h"
34
#elif defined _SYSTEM_WIN32_
35
# include "SemaphoreImplWin32.h"
36
#else
37
# error "No semaphore implementation defined for this platform."
38
#endif
39
40
namespace
icl_core
{
41
namespace
logging {
42
43
Semaphore::Semaphore
(
size_t
initial_value)
44
: m_impl(0)
45
{
46
#if defined _SYSTEM_LXRT_
47
// Only create an LXRT implementation if the LXRT runtime system
48
// is really available. Otherwise create an ACE or POSIX implementation,
49
// depending on the system configuration.
50
// Remark: This allows us to compile programs with LXRT support but run
51
// them on systems on which no LXRT is installed and to disable LXRT support
52
// at program startup on systems with installed LXRT!
53
if
(
icl_core::os::isLxrtAvailable
())
54
{
55
m_impl
=
new
SemaphoreImplLxrt(initial_value);
56
}
57
else
58
{
59
m_impl
=
new
SemaphoreImplPosix
(initial_value);
60
}
61
62
#elif defined _SYSTEM_DARWIN_
63
m_impl
=
new
SemaphoreImplDarwin
(initial_value);
64
65
#elif defined _SYSTEM_POSIX_
66
m_impl
=
new
SemaphoreImplPosix
(initial_value);
67
68
#elif defined _SYSTEM_WIN32_
69
m_impl
=
new
SemaphoreImplWin32
(initial_value);
70
71
#endif
72
}
73
74
Semaphore::~Semaphore
()
75
{
76
delete
m_impl
;
77
m_impl
= 0;
78
}
79
80
void
Semaphore::post
()
81
{
82
return
m_impl
->
post
();
83
}
84
85
bool
Semaphore::wait
()
86
{
87
return
m_impl
->
wait
();
88
}
89
91
#ifdef _IC_BUILDER_DEPRECATED_STYLE_
92
94
void
Semaphore::Post()
95
{
96
post
();
97
}
98
105
bool
Semaphore::Wait()
106
{
107
return
wait
();
108
}
109
110
#endif
111
113
}
114
}
icl_core::logging::Semaphore::~Semaphore
virtual ~Semaphore()
Definition:
Semaphore.cpp:74
icl_core::logging::Semaphore::post
void post()
Increments the semaphore.
Definition:
Semaphore.cpp:80
icl_core::logging::SemaphoreImpl::post
virtual void post()=0
icl_core::logging::SemaphoreImplWin32
Definition:
icl_core_logging/SemaphoreImplWin32.h:37
icl_core::logging::SemaphoreImplPosix
Definition:
icl_core_logging/SemaphoreImplPosix.h:37
icl_core::os::isLxrtAvailable
bool isLxrtAvailable()
Definition:
os_lxrt.cpp:141
icl_core::logging::SemaphoreImpl::wait
virtual bool wait()=0
icl_core::logging::Semaphore::m_impl
SemaphoreImpl * m_impl
Definition:
Semaphore.h:79
icl_core::logging::Semaphore::wait
bool wait()
Definition:
Semaphore.cpp:85
icl_core
Definition:
Array2D.h:30
icl_core::logging::SemaphoreImplDarwin
Definition:
icl_core_logging/SemaphoreImplDarwin.h:38
Semaphore.h
Contains icl_core::logging::Semaphore.
icl_core::logging::Semaphore::Semaphore
Semaphore(size_t initial_value=1)
Definition:
Semaphore.cpp:43
fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:58