Fawkes API Fawkes Development Version
mutex.h
1
2/***************************************************************************
3 * mutex.h - Mutex
4 *
5 * Generated: Thu Sep 14 16:58:49 2006
6 * Copyright 2006 Tim Niemueller [www.niemueller.de]
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22 */
23
24#ifndef _CORE_THREADING_MUTEX_H_
25#define _CORE_THREADING_MUTEX_H_
26
27namespace fawkes {
28
29class MutexData;
30class WaitCondition;
31
32class Mutex
33{
34 friend WaitCondition;
35
36public:
37 /** Mutex type. */
38 typedef enum {
39 NORMAL, ///< This type of mutex does not detect deadlock.
40 RECURSIVE ///< A thread attempting to relock this mutex without
41 ///< first unlocking it shall succeed in locking the mutex.
43
44 Mutex(Type type = NORMAL);
45 ~Mutex();
46
47 void lock();
48 bool try_lock();
49 void unlock();
50
51 void stopby();
52
53private:
54 MutexData *mutex_data;
55};
56
57} // end namespace fawkes
58
59#endif
Mutex mutual exclusion lock.
Definition: mutex.h:33
~Mutex()
Destructor.
Definition: mutex.cpp:75
bool try_lock()
Tries to lock the mutex.
Definition: mutex.cpp:117
Type
Mutex type.
Definition: mutex.h:38
@ NORMAL
This type of mutex does not detect deadlock.
Definition: mutex.h:39
@ RECURSIVE
A thread attempting to relock this mutex without first unlocking it shall succeed in locking the mute...
Definition: mutex.h:40
void lock()
Lock this mutex.
Definition: mutex.cpp:87
void stopby()
Shortly stop by at the mutex.
Definition: mutex.cpp:150
void unlock()
Unlock the mutex.
Definition: mutex.cpp:131
Mutex(Type type=NORMAL)
Constructor.
Definition: mutex.cpp:59
Wait until a given condition holds.
Fawkes library namespace.