ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 1e6b350 was
cc7f4b1,
checked in by Thierry Delisle <tdelisle@…>, 8 years ago
|
- renamed monitor to monitor_t since the type should not be exposed to users
- added support for recursion in monitors
|
-
Property mode set to
100644
|
File size:
1017 bytes
|
Line | |
---|
1 | // -*- Mode: CFA -*- |
---|
2 | // |
---|
3 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo |
---|
4 | // |
---|
5 | // The contents of this file are covered under the licence agreement in the |
---|
6 | // file "LICENCE" distributed with Cforall. |
---|
7 | // |
---|
8 | // monitor -- |
---|
9 | // |
---|
10 | // Author : Thierry Delisle |
---|
11 | // Created On : Thd Feb 23 12:27:26 2017 |
---|
12 | // Last Modified By : Thierry Delisle |
---|
13 | // Last Modified On : -- |
---|
14 | // Update Count : 0 |
---|
15 | // |
---|
16 | |
---|
17 | #ifndef MONITOR_H |
---|
18 | #define MONITOR_H |
---|
19 | |
---|
20 | #include "assert" |
---|
21 | #include "invoke.h" |
---|
22 | |
---|
23 | struct __monitor_t { |
---|
24 | spinlock lock; |
---|
25 | thread * owner; |
---|
26 | simple_thread_list entry_queue; |
---|
27 | unsigned int recursion; |
---|
28 | }; |
---|
29 | |
---|
30 | static inline void ?{}(__monitor_t * this) { |
---|
31 | this->owner = 0; |
---|
32 | this->recursion = 0; |
---|
33 | } |
---|
34 | |
---|
35 | void enter(__monitor_t *); |
---|
36 | void leave(__monitor_t *); |
---|
37 | |
---|
38 | struct monitor_guard_t { |
---|
39 | __monitor_t * m; |
---|
40 | }; |
---|
41 | |
---|
42 | static inline void ?{}( monitor_guard_t * this, __monitor_t * m ) { |
---|
43 | this->m = m; |
---|
44 | enter( this->m ); |
---|
45 | } |
---|
46 | |
---|
47 | static inline void ^?{}( monitor_guard_t * this ) { |
---|
48 | leave( this->m ); |
---|
49 | } |
---|
50 | |
---|
51 | #endif //MONITOR_H |
---|
Note: See
TracBrowser
for help on using the repository browser.