Changeset 4ee36bf0 for src/libcfa/concurrency/monitor
- Timestamp:
- Nov 8, 2017, 2:50:35 PM (8 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 049ead9
- Parents:
- 136ccd7 (diff), e35f30a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/monitor
r136ccd7 r4ee36bf0 39 39 } 40 40 41 // static inline int ?<?(monitor_desc* lhs, monitor_desc* rhs) {42 // return ((intptr_t)lhs) < ((intptr_t)rhs);43 // }44 45 41 struct monitor_guard_t { 46 42 monitor_desc ** m; 47 intcount;43 __lock_size_t count; 48 44 monitor_desc ** prev_mntrs; 49 unsigned shortprev_count;45 __lock_size_t prev_count; 50 46 fptr_t prev_func; 51 47 }; 52 48 53 void ?{}( monitor_guard_t & this, monitor_desc ** m, int count, void (*func)() );49 void ?{}( monitor_guard_t & this, monitor_desc ** m, __lock_size_t count, void (*func)() ); 54 50 void ^?{}( monitor_guard_t & this ); 55 51 … … 57 53 monitor_desc * m; 58 54 monitor_desc ** prev_mntrs; 59 unsigned shortprev_count;55 __lock_size_t prev_count; 60 56 fptr_t prev_func; 61 57 }; … … 74 70 75 71 struct __condition_criterion_t { 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 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; 80 83 }; 81 84 82 85 struct __condition_node_t { 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 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; 88 100 }; 89 101 … … 93 105 }; 94 106 95 void ?{}(__condition_node_t & this, thread_desc * waiting_thread, unsigned short count, uintptr_t user_info );107 void ?{}(__condition_node_t & this, thread_desc * waiting_thread, __lock_size_t count, uintptr_t user_info ); 96 108 void ?{}(__condition_criterion_t & this ); 97 109 void ?{}(__condition_criterion_t & this, monitor_desc * target, __condition_node_t * owner ); 98 110 99 111 void ?{}( __condition_blocked_queue_t & ); 100 void append( __condition_blocked_queue_t *, __condition_node_t * );101 __condition_node_t * pop_head( __condition_blocked_queue_t *);112 void append( __condition_blocked_queue_t &, __condition_node_t * ); 113 __condition_node_t * pop_head( __condition_blocked_queue_t & ); 102 114 103 115 struct condition { 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 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; 107 124 }; 108 125 … … 116 133 } 117 134 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 );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 ); 123 140 124 141 //-----------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.