Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/monitor

    r59a0bde r751d963  
    3939}
    4040
     41// static inline int ?<?(monitor_desc* lhs, monitor_desc* rhs) {
     42//      return ((intptr_t)lhs) < ((intptr_t)rhs);
     43// }
     44
    4145struct monitor_guard_t {
    4246        monitor_desc ** m;
    43         __lock_size_t  count;
     47        int count;
    4448        monitor_desc ** prev_mntrs;
    45         __lock_size_t   prev_count;
     49        unsigned short  prev_count;
    4650        fptr_t          prev_func;
    4751};
    4852
    49 void ?{}( monitor_guard_t & this, monitor_desc ** m, __lock_size_t count, void (*func)() );
     53void ?{}( monitor_guard_t & this, monitor_desc ** m, int count, void (*func)() );
    5054void ^?{}( monitor_guard_t & this );
    5155
     
    5357        monitor_desc * m;
    5458        monitor_desc ** prev_mntrs;
    55         __lock_size_t   prev_count;
     59        unsigned short  prev_count;
    5660        fptr_t          prev_func;
    5761};
     
    7074
    7175struct __condition_criterion_t {
    72         // Whether or not the criterion is met (True if met)
    73         bool ready;
    74 
    75         // The monitor this criterion concerns
    76         monitor_desc * target;
    77 
    78         // The parent node to which this criterion belongs
    79         struct __condition_node_t * owner;
    80 
    81         // Intrusive linked list Next field
    82         __condition_criterion_t * next;
     76        bool ready;                                             //Whether or not the criterion is met (True if met)
     77        monitor_desc * target;                          //The monitor this criterion concerns
     78        struct __condition_node_t * owner;              //The parent node to which this criterion belongs
     79        __condition_criterion_t * next;         //Intrusive linked list Next field
    8380};
    8481
    8582struct __condition_node_t {
    86         // Thread that needs to be woken when all criteria are met
    87         thread_desc * waiting_thread;
    88 
    89         // Array of criteria (Criterions are contiguous in memory)
    90         __condition_criterion_t * criteria;
    91 
    92         // Number of criterions in the criteria
    93         __lock_size_t count;
    94 
    95         // Intrusive linked list Next field
    96         __condition_node_t * next;
    97 
    98         // Custom user info accessible before signalling
    99         uintptr_t user_info;
     83        thread_desc * waiting_thread;                   //Thread that needs to be woken when all criteria are met
     84        __condition_criterion_t * criteria;     //Array of criteria (Criterions are contiguous in memory)
     85        unsigned short count;                           //Number of criterions in the criteria
     86        __condition_node_t * next;                      //Intrusive linked list Next field
     87        uintptr_t user_info;                            //Custom user info accessible before signalling
    10088};
    10189
     
    10593};
    10694
    107 void ?{}(__condition_node_t & this, thread_desc * waiting_thread, __lock_size_t count, uintptr_t user_info );
     95void ?{}(__condition_node_t & this, thread_desc * waiting_thread, unsigned short count, uintptr_t user_info );
    10896void ?{}(__condition_criterion_t & this );
    10997void ?{}(__condition_criterion_t & this, monitor_desc * target, __condition_node_t * owner );
    11098
    11199void ?{}( __condition_blocked_queue_t & );
    112 void append( __condition_blocked_queue_t &, __condition_node_t * );
    113 __condition_node_t * pop_head( __condition_blocked_queue_t & );
     100void append( __condition_blocked_queue_t *, __condition_node_t * );
     101__condition_node_t * pop_head( __condition_blocked_queue_t * );
    114102
    115103struct condition {
    116         // Link list which contains the blocked threads as-well as the information needed to unblock them
    117         __condition_blocked_queue_t blocked;
    118 
    119         // Array of monitor pointers (Monitors are NOT contiguous in memory)
    120         monitor_desc ** monitors;
    121 
    122         // Number of monitors in the array
    123         __lock_size_t monitor_count;
     104        __condition_blocked_queue_t blocked;    //Link list which contains the blocked threads as-well as the information needed to unblock them
     105        monitor_desc ** monitors;                       //Array of monitor pointers (Monitors are NOT contiguous in memory)
     106        unsigned short monitor_count;                   //Number of monitors in the array
    124107};
    125108
     
    133116}
    134117
    135               void wait        ( condition & this, uintptr_t user_info = 0 );
    136               bool signal      ( condition & this );
    137               bool signal_block( condition & this );
    138 static inline bool is_empty    ( condition & this ) { return !this.blocked.head; }
    139          uintptr_t front       ( condition & this );
     118void wait( condition * this, uintptr_t user_info = 0 );
     119bool signal( condition * this );
     120bool signal_block( condition * this );
     121static inline bool is_empty( condition * this ) { return !this->blocked.head; }
     122uintptr_t front( condition * this );
    140123
    141124//-----------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.