YARP
Yet Another Robot Platform
RecursiveMutex.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#define YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
8#undef YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
9
10#include <mutex>
11
13
15{
16public:
17 std::recursive_mutex mutex;
18};
19
20RecursiveMutex::RecursiveMutex() :
21 mPriv(new Private)
22{
23}
24
26{
27 delete mPriv;
28}
29
31{
32 mPriv->mutex.lock();
33}
34
36{
37 return mPriv->mutex.try_lock();
38}
39
41{
42 mPriv->mutex.unlock();
43}
44
46{
47 return mPriv->mutex.try_lock();
48}
RecursiveMutex offers exclusive, recursive ownership semantics:
void unlock()
Unlock the associated resource thus freeing waiting threads.
bool try_lock()
Lock the associated resource if it is free.
bool tryLock()
Lock the associated resource if it is free.
void lock()
Lock the associated resource, waiting if the resource is busy.