Home
Roadside
Carputer
geoHist
software
FRC
Blog
Now you can download a copy of these docs so you can use them offline!
Download now
Main Page
Related Pages
Classes
Files
File List
Synchronized.h
1
/*----------------------------------------------------------------------------*/
2
/* Copyright (c) FIRST 2008. All Rights Reserved. */
3
/* Open Source Software - may be modified and shared by FRC teams. The code */
4
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
5
/*----------------------------------------------------------------------------*/
6
7
#ifndef SYNCHRONIZED_H
8
#define SYNCHRONIZED_H
9
10
#include <semLib.h>
11
12
#include "Base.h"
13
14
#define CRITICAL_REGION(s) { Synchronized _sync(s);
15
#define END_REGION }
16
17
class
Synchronized
;
18
31
class
ReentrantSemaphore
32
{
33
public
:
34
explicit
ReentrantSemaphore
() {
35
m_semaphore = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE);
36
}
37
~
ReentrantSemaphore
() {
38
semDelete(m_semaphore);
39
}
40
45
int
take
() {
46
return
semTake(m_semaphore, WAIT_FOREVER);
47
}
48
53
int
give
() {
54
return
semGive(m_semaphore);
55
}
56
57
private
:
58
SEM_ID m_semaphore;
59
60
friend
class
Synchronized
;
61
DISALLOW_COPY_AND_ASSIGN(
ReentrantSemaphore
);
62
};
63
82
class
Synchronized
83
{
84
public
:
85
explicit
Synchronized
(SEM_ID);
86
explicit
Synchronized
(
ReentrantSemaphore
&);
87
virtual
~Synchronized
();
88
private
:
89
SEM_ID m_semaphore;
90
91
DISALLOW_COPY_AND_ASSIGN(
Synchronized
);
92
};
93
94
#endif
ReentrantSemaphore::take
int take()
Definition:
Synchronized.h:45
Synchronized
Definition:
Synchronized.h:82
Synchronized::Synchronized
Synchronized(SEM_ID)
Definition:
Synchronized.cpp:17
Synchronized::~Synchronized
virtual ~Synchronized()
Definition:
Synchronized.cpp:32
ReentrantSemaphore
Definition:
Synchronized.h:31
ReentrantSemaphore::give
int give()
Definition:
Synchronized.h:53
Generated on Sat Apr 26 2014 12:26:45 for WPILibC++ by
1.8.6
© 2006-2009 Dustin Spicuzza. All rights reserved.
Powered by Onnac
I do not condone or encourage graffiti. Please paint responsibly.