-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent.cpp
53 lines (48 loc) · 1.33 KB
/
event.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// File: event.cpp
// Uros Bojanic 2019/0077
// Preprocessor directives
#include "event.h"
#include "kerEv.h"
#include "lock.h"
#include <stdlib.h>
Event::Event(IVTNo ivtNo) {
/* Creates new Event object by delegating the
* call to KernelEv constructor (kernel implementation
* of Event is stored as a dynamic variable).
* This function is as a wrapper with locking ensured.
*/
#ifndef BCC_BLOCK_IGNORE
prevent_context_switching_lock(); // lock
#endif
myImpl = new KernelEv(ivtNo); // create event
#ifndef BCC_BLOCK_IGNORE
prevent_context_switching_unlock(); // unlock
#endif
}
Event::~Event() {
/* Deletes this Event object by destructing the
* associated KernelEv object (kernel implementation
* of Event is stored as a dynamic variable).
* This function is as a wrapper with locking ensured.
*/
#ifndef BCC_BLOCK_IGNORE
prevent_context_switching_lock(); // lock
#endif
delete myImpl; // delete event
myImpl = NULL;
#ifndef BCC_BLOCK_IGNORE
prevent_context_switching_unlock(); // unlock
#endif
}
void Event::wait() {
/* Delegates call to KernelEv's wait() implementation.
* This function is as a wrapper with locking ensured later.
*/
myImpl->wait();
}
void Event::signal() {
/* Delegates call to KernelEv's signal() implementation.
* This function is as a wrapper with locking ensured later.
*/
myImpl->signal();
}