Ignore:
Timestamp:
Feb 28, 2017, 4:21:15 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
20221d4
Parents:
cc7f4b1
Message:

added support for acquiring multiple monitors at once

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/monitor

    rcc7f4b1 r2781e65  
    2020#include "assert"
    2121#include "invoke.h"
     22#include "stdlib"
    2223
    2324struct __monitor_t {
     
    3334}
    3435
     36//Basic entering routine
    3537void enter(__monitor_t *);
    3638void leave(__monitor_t *);
    3739
     40//Array entering routine
     41void enter(__monitor_t **, int count);
     42void leave(__monitor_t **, int count);
     43
    3844struct monitor_guard_t {
    39         __monitor_t * m;
     45        __monitor_t ** m;
     46        int count;
    4047};
    4148
    42 static inline void ?{}( monitor_guard_t * this, __monitor_t * m ) {
     49static inline int ?<?(__monitor_t* lhs, __monitor_t* rhs) {
     50        return ((intptr_t)lhs) < ((intptr_t)rhs);
     51}
     52
     53static inline void ?{}( monitor_guard_t * this, __monitor_t ** m ) {
    4354        this->m = m;
    44         enter( this->m );
     55        this->count = 1;
     56        enter( *this->m );
     57}
     58
     59static 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 );
    4564}
    4665
    4766static inline void ^?{}( monitor_guard_t * this ) {
    48         leave( this->m );
     67        leave( this->m, this->count );
    4968}
    5069
     70
    5171#endif //MONITOR_H
Note: See TracChangeset for help on using the changeset viewer.