LRT14
1.0
Main Page
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Enumerations
Enumerator
lock_ptr.hpp
1
#ifndef LOCK_PTR_H_
2
#define LOCK_PTR_H_
3
4
#include "SyncObject.h"
5
6
#include <WPILib.h>
7
8
namespace
Rhesus
9
{
10
namespace
Toolkit
11
{
12
namespace
Tasks
13
{
14
template
<
class
T>
15
class
lock_ptr
16
{
17
public
:
18
lock_ptr(
volatile
T& lockObj, SyncObject& mutex)
19
: m_lockObj(const_cast<T*>(&lockObj)),
20
m_mutex(mutex)
21
{
22
m_mutex.lock();
23
}
24
25
~lock_ptr()
26
{
27
m_mutex.unlock();
28
}
29
30
T& operator*()
31
{
32
return
*m_lockObj;
33
}
34
35
T* operator->()
36
{
37
return
m_lockObj;
38
}
39
40
private
:
41
T* m_lockObj;
42
SyncObject& m_mutex;
43
44
DISALLOW_COPY_AND_ASSIGN(lock_ptr);
45
};
46
}
47
}
48
}
49
50
#endif
Rhesus
Toolkit
Tasks
lock_ptr.hpp
Generated on Thu Jan 9 2014 15:47:16 for LRT14 by
1.8.3