source:
src/libcfa/concurrency/monitor@
78d3dd5
| Last change on this file since 78d3dd5 was 690f13c, checked in by , 9 years ago | |
|---|---|
|
|
| File size: 1.2 KB | |
| Rev | Line | |
|---|---|---|
| [f07e037] | 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 | ||
| [690f13c] | 20 | #include <stddef.h> |
| 21 | ||
| [f07e037] | 22 | #include "assert" |
| 23 | #include "invoke.h" | |
| [2781e65] | 24 | #include "stdlib" |
| [f07e037] | 25 | |
| [84c52a8] | 26 | static inline void ?{}(monitor_desc * this) { |
| [690f13c] | 27 | this->owner = NULL; |
| 28 | this->stack_owner = NULL; | |
| [cc7f4b1] | 29 | this->recursion = 0; |
| 30 | } | |
| 31 | ||
| [2781e65] | 32 | //Array entering routine |
| [84c52a8] | 33 | void enter(monitor_desc **, int count); |
| 34 | void leave(monitor_desc **, int count); | |
| [2781e65] | 35 | |
| [cc7f4b1] | 36 | struct monitor_guard_t { |
| [84c52a8] | 37 | monitor_desc ** m; |
| [2781e65] | 38 | int count; |
| [51f3798] | 39 | }; |
| 40 | ||
| [84c52a8] | 41 | static inline int ?<?(monitor_desc* lhs, monitor_desc* rhs) { |
| [2781e65] | 42 | return ((intptr_t)lhs) < ((intptr_t)rhs); |
| 43 | } | |
| 44 | ||
| [84c52a8] | 45 | static inline void ?{}( monitor_guard_t * this, monitor_desc ** m, int count ) { |
| [2781e65] | 46 | this->m = m; |
| 47 | this->count = count; | |
| 48 | qsort(this->m, count); | |
| 49 | enter( this->m, this->count ); | |
| [51f3798] | 50 | } |
| 51 | ||
| [cc7f4b1] | 52 | static inline void ^?{}( monitor_guard_t * this ) { |
| [2781e65] | 53 | leave( this->m, this->count ); |
| [51f3798] | 54 | } |
| 55 | ||
| [2781e65] | 56 | |
| [f07e037] | 57 | #endif //MONITOR_H |
Note:
See TracBrowser
for help on using the repository browser.