Changes in / [20221d4:f37147b]


Ignore:
Location:
src
Files:
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/monitor

    r20221d4 rf37147b  
    2020#include "assert"
    2121#include "invoke.h"
    22 #include "stdlib"
    2322
    2423struct __monitor_t {
     
    3433}
    3534
    36 //Basic entering routine
    3735void enter(__monitor_t *);
    3836void leave(__monitor_t *);
    3937
    40 //Array entering routine
    41 void enter(__monitor_t **, int count);
    42 void leave(__monitor_t **, int count);
    43 
    4438struct monitor_guard_t {
    45         __monitor_t ** m;
    46         int count;
     39        __monitor_t * m;
    4740};
    4841
    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 ) {
     42static inline void ?{}( monitor_guard_t * this, __monitor_t * m ) {
    5443        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 );
    6445}
    6546
    6647static inline void ^?{}( monitor_guard_t * this ) {
    67         leave( this->m, this->count );
     48        leave( this->m );
    6849}
    6950
    70 
    7151#endif //MONITOR_H
  • src/libcfa/concurrency/monitor.c

    r20221d4 rf37147b  
    7171        }
    7272}
    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  
    1616
    1717void increment( /*mutex*/ global_t * this ) {
    18         __monitor_t * mon = &this->m;
    19         monitor_guard_t g1 = { &mon };
     18        monitor_guard_t g1 = { &this->m };
    2019        {
    21                 monitor_guard_t g2 = { &mon };
     20                monitor_guard_t g2 = { &this->m };
    2221                {
    23                         monitor_guard_t g3 = { &mon };
     22                        monitor_guard_t g3 = { &this->m };
    2423                        this->value += 1;
    2524                }
Note: See TracChangeset for help on using the changeset viewer.