- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/channel.hfa
r88b49bb r5908fb4 62 62 bool closed; // indicates channel close/open 63 63 #ifdef CHAN_STATS 64 size_t p_blocks, p_ops, c_blocks, c_ops; // counts total ops and ops resulting in a blocked thd64 size_t blocks, operations; // 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 p_blocks = 0; 78 p_ops = 0; 79 c_blocks = 0; 80 c_ops = 0; 77 blocks = 0; 78 operations = 0; 81 79 #endif 82 80 } … … 85 83 static inline void ^?{}( channel(T) &c ) with(c) { 86 84 #ifdef CHAN_STATS 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" ); 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" ); 93 88 if ( size != 0 ) delete( buffer ); 94 89 } … … 154 149 lock( mutex_lock ); 155 150 #ifdef CHAN_STATS 156 p_ops++;151 operations++; 157 152 #endif 158 153 … … 192 187 193 188 #ifdef CHAN_STATS 194 if ( !closed ) p_ops++;189 if ( !closed ) operations++; 195 190 #endif 196 191 … … 213 208 if ( count == size ) { 214 209 #ifdef CHAN_STATS 215 p_blocks++;210 blocks++; 216 211 #endif 217 212 … … 242 237 lock( mutex_lock ); 243 238 #ifdef CHAN_STATS 244 c_ops++;239 operations++; 245 240 #endif 246 241 … … 290 285 291 286 #ifdef CHAN_STATS 292 if ( !closed ) c_ops++;287 if ( !closed ) operations++; 293 288 #endif 294 289 … … 310 305 if ( count == 0 ) { 311 306 #ifdef CHAN_STATS 312 c_blocks++;307 blocks++; 313 308 #endif 314 309 // check for if woken due to close … … 328 323 /////////////////////////////////////////////////////////////////////////////////////////// 329 324 static inline bool unregister_chan( channel(T) & chan, select_node & node ) with(chan) { 330 if ( !node`isListed && !node.park_counter ) return false; // handle special OR case325 // if ( !node`isListed && !node.park_counter ) return false; // handle special OR case C_TODO: try adding this back 331 326 lock( mutex_lock ); 332 327 if ( node`isListed ) { // op wasn't performed 328 #ifdef CHAN_STATS 329 operations--; 330 #endif 333 331 remove( node ); 334 332 unlock( mutex_lock ); … … 364 362 365 363 #ifdef CHAN_STATS 366 if ( !closed ) c_ops++;364 if ( !closed ) operations++; 367 365 #endif 368 366 … … 409 407 if ( count == 0 ) { 410 408 #ifdef CHAN_STATS 411 c_blocks++;409 blocks++; 412 410 #endif 413 411 … … 453 451 454 452 #ifdef CHAN_STATS 455 if ( !closed ) p_ops++;453 if ( !closed ) operations++; 456 454 #endif 457 455 … … 500 498 if ( count == size ) { 501 499 #ifdef CHAN_STATS 502 p_blocks++;500 blocks++; 503 501 #endif 504 502
Note: See TracChangeset
for help on using the changeset viewer.