Changeset d61d034
- Timestamp:
- Jan 13, 2023, 4:30:28 PM (9 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 34a1d2e, 997185e
- Parents:
- 8bb86ce (diff), 42b739d7 (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. - Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/channel.hfa
r8bb86ce rd61d034 35 35 static inline void ?{}( channel(T) &c ){ ((channel(T) &)c){ 0 }; } 36 36 static inline void ^?{}( channel(T) &c ) with(c) { delete( buffer ); } 37 inline size_t get_count( channel(T) & chan ) with(chan) { return count; } 38 inline size_t get_size( channel(T) & chan ) with(chan) { return size; } 37 static inline size_t get_count( channel(T) & chan ) with(chan) { return count; } 38 static inline size_t get_size( channel(T) & chan ) with(chan) { return size; } 39 static inline bool has_waiters( channel(T) & chan ) with(chan) { return !empty( cons ) || !empty( prods ); } 40 static inline bool has_waiting_consumers( channel(T) & chan ) with(chan) { return !empty( cons ); } 41 static inline bool has_waiting_producers( channel(T) & chan ) with(chan) { return !empty( prods ); } 39 42 40 inline void insert_( channel(T) & chan, T elem ) with(chan) {43 static inline void insert_( channel(T) & chan, T elem ) with(chan) { 41 44 memcpy((void *)&buffer[back], (void *)&elem, sizeof(T)); 42 45 count += 1; … … 46 49 47 50 48 inline void insert( channel(T) & chan, T elem ) with(chan) {51 static inline void insert( channel(T) & chan, T elem ) with(chan) { 49 52 lock( mutex_lock ); 50 53 … … 72 75 } 73 76 74 inline T remove( channel(T) & chan ) with(chan) {77 static inline T remove( channel(T) & chan ) with(chan) { 75 78 lock( mutex_lock ); 76 79 T retval; -
tests/concurrent/channels/parallel_harness.hfa
r8bb86ce rd61d034 38 38 39 39 volatile bool cons_done = false, prod_done = false; 40 volatile int cons_done_count = 0; 40 41 size_t cons_check = 0, prod_check = 0; 41 42 … … 64 65 lock(o); 65 66 total_operations += runs; 67 cons_done_count++; 66 68 cons_check = cons_check ^ my_check; 67 69 // sout | "C: " | runs; … … 128 130 } 129 131 130 sleep(1 0`s);132 sleep(1`s); 131 133 prod_done = true; 132 134 … … 137 139 sout | "prods"; 138 140 cons_done = true; 139 for ( i; Channels ) { 140 // sout | get_count( channels[i] ); 141 if ( get_count( channels[i] ) < Consumers ){ 142 #ifdef BIG 143 bigObject b{0}; 144 #endif 145 for ( j; Consumers ) { 141 while( cons_done_count != Consumers * Channels ) { 142 for ( i; Channels ) { 143 if ( has_waiting_consumers( channels[i] ) ){ 146 144 #ifdef BIG 145 bigObject b{0}; 147 146 insert( channels[i], b ); 148 147 #else … … 151 150 } 152 151 } 153 } 152 153 } 154 // for ( i; Channels ) { 155 // // sout | get_count( channels[i] ); 156 // if ( get_count( channels[i] ) < Consumers ){ 157 // #ifdef BIG 158 // bigObject b{0}; 159 // #endif 160 // for ( j; Consumers ) { 161 // #ifdef BIG 162 // insert( channels[i], b ); 163 // #else 164 // insert( channels[i], 0 ); 165 // #endif 166 // } 167 // } 168 // } 154 169 sout | "cons"; 155 170 for ( i; Consumers * Channels ) { -
tests/concurrent/channels/zero_size.cfa
r8bb86ce rd61d034 1 1 #include "parallel_harness.hfa" 2 2 3 size_t Processors = 10, Channels = 1 0, Producers = 40, Consumers = 40, ChannelSize = 0;3 size_t Processors = 10, Channels = 1, Producers = 10, Consumers = 10, ChannelSize = 0; 4 4 5 5 int main() {
Note: See TracChangeset
for help on using the changeset viewer.