- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/ready_queue.cfa
r28d73c1 rd72c074 186 186 //======================================================================= 187 187 void ?{}(__ready_queue_t & this) with (this) { 188 lanes.data = 0p; 189 lanes.count = 0; 188 189 lanes.data = alloc(4); 190 for( i; 4 ) { 191 (lanes.data[i]){}; 192 } 193 lanes.count = 4; 194 snzi{ log2( lanes.count / 8 ) }; 190 195 } 191 196 192 197 void ^?{}(__ready_queue_t & this) with (this) { 193 verify( 0== lanes.count );198 verify( 4 == lanes.count ); 194 199 verify( !query( snzi ) ); 200 201 ^(snzi){}; 202 203 for( i; 4 ) { 204 ^(lanes.data[i]){}; 205 } 195 206 free(lanes.data); 196 207 } … … 484 495 } 485 496 486 #warning remove when alloc is fixed487 forall( dtype T | sized(T) )488 static inline T * correct_alloc( T ptr[], size_t dim ) {489 if( dim == 0 ) {490 free(ptr);491 return 0p;492 }493 T * temp = alloc( dim );494 if(ptr) {495 memcpy( temp, ptr, dim * sizeof(T));496 free(ptr);497 }498 return temp;499 }500 501 497 // Grow the ready queue 502 498 void ready_queue_grow (struct cluster * cltr) { … … 517 513 518 514 // Allocate new array (uses realloc and memcpies the data) 519 lanes.data = correct_alloc(lanes.data, ncount);515 lanes.data = alloc(lanes.data, ncount); 520 516 521 517 // Fix the moved data … … 562 558 size_t ocount = lanes.count; 563 559 // Check that we have some space left 564 if(ocount < 4) abort("Program attempted to destroy more Ready Queues than were created");560 if(ocount < 8) abort("Program attempted to destroy more Ready Queues than were created"); 565 561 566 562 // reduce the actual count so push doesn't use the old queues … … 604 600 605 601 // Allocate new array (uses realloc and memcpies the data) 606 lanes.data = correct_alloc(lanes.data, lanes.count);602 lanes.data = alloc(lanes.data, lanes.count); 607 603 608 604 // Fix the moved data
Note:
See TracChangeset
for help on using the changeset viewer.