YARP
Yet Another Robot Platform
Mutex.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/Mutex.h>
11 #undef YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
12 
15 
16 #include <mutex>
17 
18 using yarp::os::Mutex;
19 
20 class Mutex::Private : public std::mutex
21 {
22 };
23 
24 Mutex::Mutex() :
25  mPriv(new Private)
26 {
27 }
28 
30 {
31  delete mPriv;
32 }
33 
35 {
36  mPriv->lock();
37 }
38 
40 {
41  return mPriv->try_lock();
42 }
43 
45 {
46  mPriv->unlock();
47 }
48 
50 {
51  return mPriv->try_lock();
52 }
53 
YARP_WARNING_PUSH
#define YARP_WARNING_PUSH
Starts a temporary alteration of the enabled warnings.
Definition: system.h:334
yarp::os::Mutex::try_lock
bool try_lock()
Lock the associated resource if possible.
Definition: Mutex.cpp:39
yarp::os::Mutex::tryLock
bool tryLock()
Lock the associated resource if possible.
Definition: Mutex.cpp:49
yarp::os::Mutex::Private
Definition: Mutex.cpp:21
yarp::os::Mutex::~Mutex
~Mutex()
Destructor.
Definition: Mutex.cpp:29
YARP_WARNING_POP
#define YARP_WARNING_POP
Ends a temporary alteration of the enabled warnings.
Definition: system.h:335
Mutex.h
yarp::os::Mutex
Basic wrapper for mutual exclusion.
Definition: Mutex.h:35
yarp::os::Mutex::lock
void lock()
Lock the associated resource, waiting if necessary.
Definition: Mutex.cpp:34
YARP_DISABLE_DEPRECATED_WARNING
#define YARP_DISABLE_DEPRECATED_WARNING
Disable deprecated warnings in the following code.
Definition: system.h:336
yarp::os::Mutex::unlock
void unlock()
Unlock the associated resource.
Definition: Mutex.cpp:44