Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Semaphore.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012-2021 Euclid Science Ground Segment
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 3.0 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
20#ifdef __APPLE__
21#include "SemaphoreMach.icpp"
22#else
23#include "SemaphorePosix.icpp"
24#endif
25
26namespace Euclid {
27
28Semaphore::Semaphore(unsigned int i) : m_impl(new SemaphoreImpl(i)) {}
29
30Semaphore::~Semaphore() = default;
31
33 m_impl->post();
34}
35
37 m_impl->wait();
38}
39
41 return m_impl->try_acquire();
42}
43
44bool Semaphore::try_acquire_until(const std::chrono::system_clock::time_point& abs_time) {
45 return m_impl->try_acquire_until(abs_time);
46}
47
48} // namespace Euclid
Semaphore(unsigned int i)
Definition Semaphore.cpp:28
bool try_acquire_until(const std::chrono::system_clock::time_point &abs_time)
Definition Semaphore.cpp:44
std::unique_ptr< SemaphoreImpl > m_impl
Definition Semaphore.h:100