source: rrlib_thread/tMutex.h @ 0:c2492b69e880

Last change on this file since 0:c2492b69e880 was 0:c2492b69e880, checked in by Max Reichardt <mreichardt@…>, 7 years ago

Initial commit. These are refactored thread classes that were moved out of finroc_core_utils.

File size: 3.1 KB
Line 
1//
2// You received this file as part of RRLib
3// Robotics Research Library
4//
5// Copyright (C) Finroc GbR (finroc.org)
6//
7// This program is free software; you can redistribute it and/or
8// modify it under the terms of the GNU General Public License
9// as published by the Free Software Foundation; either version 2
10// of the License, or (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program; if not, write to the Free Software
19// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20//
21//----------------------------------------------------------------------
22/*!\file    rrlib/thread/tMutex.h
23 *
24 * \author  Max Reichardt
25 *
26 * \date    2012-07-04
27 *
28 * \brief   Contains tMutex
29 *
30 * \b tMutex
31 *
32 * Simple Mutex. No Mutex may be acquired after a simple mutex.
33 *
34 */
35//----------------------------------------------------------------------
36#ifndef __rrlib__thread__tMutex_h__
37#define __rrlib__thread__tMutex_h__
38
39//----------------------------------------------------------------------
40// External includes (system with <>, local with "")
41//----------------------------------------------------------------------
42#include <mutex>
43#include <boost/utility.hpp>
44
45//----------------------------------------------------------------------
46// Internal includes with ""
47//----------------------------------------------------------------------
48
49//----------------------------------------------------------------------
50// Namespace declaration
51//----------------------------------------------------------------------
52namespace rrlib
53{
54namespace thread
55{
56
57//----------------------------------------------------------------------
58// Forward declarations / typedefs / enums
59//----------------------------------------------------------------------
60class tLock;
61
62//----------------------------------------------------------------------
63// Class declaration
64//----------------------------------------------------------------------
65//! Simple Mutex.
66/*!
67 * Simple Mutex. No Mutex may be acquired after a simple mutex.
68 */
69class tMutex : boost::noncopyable
70{
71  friend class tLock;
72
73//----------------------------------------------------------------------
74// Public methods and typedefs
75//----------------------------------------------------------------------
76public:
77
78  typedef rrlib::thread::tLock tLock;
79
80  explicit tMutex() {}
81
82//----------------------------------------------------------------------
83// Private fields and methods
84//----------------------------------------------------------------------
85private:
86
87#ifndef RRLIB_SINGLE_THREADED
88
89  /*! Wrapped mutex class */
90  mutable std::mutex wrapped;
91
92#endif
93};
94
95//----------------------------------------------------------------------
96// End of namespace declaration
97//----------------------------------------------------------------------
98}
99}
100
101
102#endif
Note: See TracBrowser for help on using the repository browser.