Changes in src/libcfa/concurrency/monitor [59a0bde:751d963]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/monitor
r59a0bde r751d963 39 39 } 40 40 41 // static inline int ?<?(monitor_desc* lhs, monitor_desc* rhs) { 42 // return ((intptr_t)lhs) < ((intptr_t)rhs); 43 // } 44 41 45 struct monitor_guard_t { 42 46 monitor_desc ** m; 43 __lock_size_tcount;47 int count; 44 48 monitor_desc ** prev_mntrs; 45 __lock_size_tprev_count;49 unsigned short prev_count; 46 50 fptr_t prev_func; 47 51 }; 48 52 49 void ?{}( monitor_guard_t & this, monitor_desc ** m, __lock_size_t count, void (*func)() );53 void ?{}( monitor_guard_t & this, monitor_desc ** m, int count, void (*func)() ); 50 54 void ^?{}( monitor_guard_t & this ); 51 55 … … 53 57 monitor_desc * m; 54 58 monitor_desc ** prev_mntrs; 55 __lock_size_tprev_count;59 unsigned short prev_count; 56 60 fptr_t prev_func; 57 61 }; … … 70 74 71 75 struct __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 83 80 }; 84 81 85 82 struct __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 100 88 }; 101 89 … … 105 93 }; 106 94 107 void ?{}(__condition_node_t & this, thread_desc * waiting_thread, __lock_size_t count, uintptr_t user_info );95 void ?{}(__condition_node_t & this, thread_desc * waiting_thread, unsigned short count, uintptr_t user_info ); 108 96 void ?{}(__condition_criterion_t & this ); 109 97 void ?{}(__condition_criterion_t & this, monitor_desc * target, __condition_node_t * owner ); 110 98 111 99 void ?{}( __condition_blocked_queue_t & ); 112 void append( __condition_blocked_queue_t &, __condition_node_t * );113 __condition_node_t * pop_head( __condition_blocked_queue_t &);100 void append( __condition_blocked_queue_t *, __condition_node_t * ); 101 __condition_node_t * pop_head( __condition_blocked_queue_t * ); 114 102 115 103 struct 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 124 107 }; 125 108 … … 133 116 } 134 117 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 );118 void wait( condition * this, uintptr_t user_info = 0 ); 119 bool signal( condition * this ); 120 bool signal_block( condition * this ); 121 static inline bool is_empty( condition * this ) { return !this->blocked.head; } 122 uintptr_t front( condition * this ); 140 123 141 124 //-----------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.