Changeset 88b49bb
- Timestamp:
- May 24, 2023, 11:46:05 AM (18 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 6c15d66
- Parents:
- 5ece8ce
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/channel.hfa
r5ece8ce r88b49bb 62 62 bool closed; // indicates channel close/open 63 63 #ifdef CHAN_STATS 64 size_t blocks, operations; // counts total ops and ops resulting in a blocked thd64 size_t p_blocks, p_ops, c_blocks, c_ops; // counts total ops and ops resulting in a blocked thd 65 65 #endif 66 66 }; … … 75 75 closed = false; 76 76 #ifdef CHAN_STATS 77 blocks = 0; 78 operations = 0; 77 p_blocks = 0; 78 p_ops = 0; 79 c_blocks = 0; 80 c_ops = 0; 79 81 #endif 80 82 } … … 83 85 static inline void ^?{}( channel(T) &c ) with(c) { 84 86 #ifdef CHAN_STATS 85 printf("Channel %p Blocks: %lu, Operations: %lu, %.2f%% of ops blocked\n", &c, blocks, operations, ((double)blocks)/operations * 100); 86 #endif 87 verifyf( cons`isEmpty && prods`isEmpty, "Attempted to delete channel with waiting threads (Deadlock).\n" ); 87 printf("Channel %p Blocks: %lu,\t\tOperations: %lu,\t%.2f%% of ops blocked\n", &c, p_blocks + c_blocks, p_ops + c_ops, ((double)p_blocks + c_blocks)/(p_ops + c_ops) * 100); 88 printf("Channel %p Consumer Blocks: %lu,\tConsumer Ops: %lu,\t%.2f%% of Consumer ops blocked\n", &c, p_blocks, p_ops, ((double)p_blocks)/p_ops * 100); 89 printf("Channel %p Producer Blocks: %lu,\tProducer Ops: %lu,\t%.2f%% of Producer ops blocked\n", &c, c_blocks, c_ops, ((double)c_blocks)/c_ops * 100); 90 #endif 91 verifyf( __handle_waituntil_OR( cons ) || __handle_waituntil_OR( prods ) || cons`isEmpty && prods`isEmpty, 92 "Attempted to delete channel with waiting threads (Deadlock).\n" ); 88 93 if ( size != 0 ) delete( buffer ); 89 94 } … … 149 154 lock( mutex_lock ); 150 155 #ifdef CHAN_STATS 151 operations++;156 p_ops++; 152 157 #endif 153 158 … … 187 192 188 193 #ifdef CHAN_STATS 189 if ( !closed ) operations++;194 if ( !closed ) p_ops++; 190 195 #endif 191 196 … … 208 213 if ( count == size ) { 209 214 #ifdef CHAN_STATS 210 blocks++;215 p_blocks++; 211 216 #endif 212 217 … … 237 242 lock( mutex_lock ); 238 243 #ifdef CHAN_STATS 239 operations++;244 c_ops++; 240 245 #endif 241 246 … … 285 290 286 291 #ifdef CHAN_STATS 287 if ( !closed ) operations++;292 if ( !closed ) c_ops++; 288 293 #endif 289 294 … … 305 310 if ( count == 0 ) { 306 311 #ifdef CHAN_STATS 307 blocks++;312 c_blocks++; 308 313 #endif 309 314 // check for if woken due to close … … 323 328 /////////////////////////////////////////////////////////////////////////////////////////// 324 329 static inline bool unregister_chan( channel(T) & chan, select_node & node ) with(chan) { 325 // if ( !node`isListed && !node.park_counter ) return false; // handle special OR case C_TODO: try adding this back330 if ( !node`isListed && !node.park_counter ) return false; // handle special OR case 326 331 lock( mutex_lock ); 327 332 if ( node`isListed ) { // op wasn't performed 328 #ifdef CHAN_STATS329 operations--;330 #endif331 333 remove( node ); 332 334 unlock( mutex_lock ); … … 362 364 363 365 #ifdef CHAN_STATS 364 if ( !closed ) operations++;366 if ( !closed ) c_ops++; 365 367 #endif 366 368 … … 407 409 if ( count == 0 ) { 408 410 #ifdef CHAN_STATS 409 blocks++;411 c_blocks++; 410 412 #endif 411 413 … … 451 453 452 454 #ifdef CHAN_STATS 453 if ( !closed ) operations++;455 if ( !closed ) p_ops++; 454 456 #endif 455 457 … … 498 500 if ( count == size ) { 499 501 #ifdef CHAN_STATS 500 blocks++;502 p_blocks++; 501 503 #endif 502 504
Note: See TracChangeset
for help on using the changeset viewer.