RTXI  2.4
The Real-Time eXperiment Interface Documentation
mutex.h
Go to the documentation of this file.
1 /*
2  The Real-Time eXperiment Interface (RTXI)
3  Copyright (C) 2011 Georgia Institute of Technology, University of Utah, Weill Cornell Medical College
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 
20 #ifndef MUTEX_H
21 #define MUTEX_H
22 
23 #include <pthread.h>
24 
28 class Mutex
29 {
30 
31 public:
32 
36  class Locker
37  {
38 
39  public:
40 
44  Locker(Mutex *m);
45  ~Locker(void);
46 
47  private:
48 
49  Mutex *mutex;
50 
51  };
52 
56  enum type_t
57  {
60  };
61 
65  Mutex(type_t type =FAST);
66  ~Mutex(void);
67 
71  void lock(void);
72 
76  void unlock(void);
77 
81  bool tryLock(void);
82 
83 private:
84 
85  pthread_mutex_t mutex;
86 
87 }; // class Mutex
88 
89 #endif // MUTEX_H
Mutex::RECURSIVE
@ RECURSIVE
Definition: mutex.h:59
Mutex::lock
void lock(void)
Definition: mutex.cpp:58
Mutex::FAST
@ FAST
Definition: mutex.h:58
Mutex::Mutex
Mutex(type_t type=FAST)
Definition: mutex.cpp:35
Mutex::Locker::~Locker
~Locker(void)
Definition: mutex.cpp:29
Mutex::tryLock
bool tryLock(void)
Definition: mutex.cpp:78
Mutex::~Mutex
~Mutex(void)
Definition: mutex.cpp:53
Mutex::type_t
type_t
Definition: mutex.h:56
Mutex
Definition: mutex.h:28
Mutex::unlock
void unlock(void)
Definition: mutex.cpp:73
Mutex::Locker
Definition: mutex.h:36
Mutex::Locker::Locker
Locker(Mutex *m)
Definition: mutex.cpp:23