Changes in / [20221d4:f37147b]
- Location:
- src
- Files:
-
- 2 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/monitor
r20221d4 rf37147b 20 20 #include "assert" 21 21 #include "invoke.h" 22 #include "stdlib"23 22 24 23 struct __monitor_t { … … 34 33 } 35 34 36 //Basic entering routine37 35 void enter(__monitor_t *); 38 36 void leave(__monitor_t *); 39 37 40 //Array entering routine41 void enter(__monitor_t **, int count);42 void leave(__monitor_t **, int count);43 44 38 struct monitor_guard_t { 45 __monitor_t ** m; 46 int count; 39 __monitor_t * m; 47 40 }; 48 41 49 static inline int ?<?(__monitor_t* lhs, __monitor_t* rhs) { 50 return ((intptr_t)lhs) < ((intptr_t)rhs); 51 } 52 53 static inline void ?{}( monitor_guard_t * this, __monitor_t ** m ) { 42 static inline void ?{}( monitor_guard_t * this, __monitor_t * m ) { 54 43 this->m = m; 55 this->count = 1; 56 enter( *this->m ); 57 } 58 59 static inline void ?{}( monitor_guard_t * this, __monitor_t ** m, int count ) { 60 this->m = m; 61 this->count = count; 62 qsort(this->m, count); 63 enter( this->m, this->count ); 44 enter( this->m ); 64 45 } 65 46 66 47 static inline void ^?{}( monitor_guard_t * this ) { 67 leave( this->m , this->count);48 leave( this->m ); 68 49 } 69 50 70 71 51 #endif //MONITOR_H -
src/libcfa/concurrency/monitor.c
r20221d4 rf37147b 71 71 } 72 72 } 73 74 void enter(__monitor_t ** monitors, int count) {75 for(int i = 0; i < count; i++) {76 // printf("%d\n", i);77 enter( monitors[i] );78 }79 }80 81 void leave(__monitor_t ** monitors, int count) {82 for(int i = count - 1; i >= 0; i--) {83 // printf("%d\n", i);84 leave( monitors[i] );85 }86 } -
src/tests/monitor.c
r20221d4 rf37147b 16 16 17 17 void increment( /*mutex*/ global_t * this ) { 18 __monitor_t * mon = &this->m; 19 monitor_guard_t g1 = { &mon }; 18 monitor_guard_t g1 = { &this->m }; 20 19 { 21 monitor_guard_t g2 = { & mon};20 monitor_guard_t g2 = { &this->m }; 22 21 { 23 monitor_guard_t g3 = { & mon};22 monitor_guard_t g3 = { &this->m }; 24 23 this->value += 1; 25 24 }
Note:
See TracChangeset
for help on using the changeset viewer.