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 
27 namespace fawkes {
28 
29 class MutexData;
30 class WaitCondition;
31 
32 class Mutex
33 {
34  friend class WaitCondition;
35 
36  public:
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.
42  } Type;
43 
44  Mutex(Type type = NORMAL);
45  ~Mutex();
46 
47  void lock();
48  bool try_lock();
49  void unlock();
50 
51  void stopby();
52 
53  private:
54  MutexData *mutex_data;
55 };
56 
57 
58 } // end namespace fawkes
59 
60 #endif
Wait until a given condition holds.
Fawkes library namespace.
void unlock()
Unlock the mutex.
Definition: mutex.cpp:135
~Mutex()
Destructor.
Definition: mutex.cpp:76
Type
Mutex type.
Definition: mutex.h:38
This type of mutex does not detect deadlock.
Definition: mutex.h:39
A thread attempting to relock this mutex without first unlocking it shall succeed in locking the mute...
Definition: mutex.h:40
bool try_lock()
Tries to lock the mutex.
Definition: mutex.cpp:120
void lock()
Lock this mutex.
Definition: mutex.cpp:89
Mutex mutual exclusion lock.
Definition: mutex.h:32
Mutex(Type type=NORMAL)
Constructor.
Definition: mutex.cpp:60
void stopby()
Shortly stop by at the mutex.
Definition: mutex.cpp:155