YARP
Yet Another Robot Platform
RecursiveMutex.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #define YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
10 #include <yarp/os/RecursiveMutex.h>
11 #undef YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
12 
13 #include <mutex>
14 
16 
18 {
19 public:
20  std::recursive_mutex mutex;
21 };
22 
23 RecursiveMutex::RecursiveMutex() :
24  mPriv(new Private)
25 {
26 }
27 
29 {
30  delete mPriv;
31 }
32 
34 {
35  mPriv->mutex.lock();
36 }
37 
39 {
40  return mPriv->mutex.try_lock();
41 }
42 
44 {
45  mPriv->mutex.unlock();
46 }
47 
49 {
50  return mPriv->mutex.try_lock();
51 }
yarp::os::RecursiveMutex
RecursiveMutex offers exclusive, recursive ownership semantics:
Definition: RecursiveMutex.h:44
RecursiveMutex.h
yarp::os::RecursiveMutex::~RecursiveMutex
~RecursiveMutex()
Destructor.
Definition: RecursiveMutex.cpp:28
yarp::os::RecursiveMutex::lock
void lock()
Lock the associated resource, waiting if the resource is busy.
Definition: RecursiveMutex.cpp:33
yarp::os::RecursiveMutex::unlock
void unlock()
Unlock the associated resource thus freeing waiting threads.
Definition: RecursiveMutex.cpp:43
yarp::os::RecursiveMutex::tryLock
bool tryLock()
Lock the associated resource if it is free.
Definition: RecursiveMutex.cpp:48
yarp::os::RecursiveMutex::Private
Definition: RecursiveMutex.cpp:18
yarp::os::RecursiveMutex::try_lock
bool try_lock()
Lock the associated resource if it is free.
Definition: RecursiveMutex.cpp:38
yarp::os::RecursiveMutex::Private::mutex
std::recursive_mutex mutex
Definition: RecursiveMutex.cpp:20