Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/ready_queue.cfa

    r28d73c1 rd72c074  
    186186//=======================================================================
    187187void ?{}(__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 ) };
    190195}
    191196
    192197void ^?{}(__ready_queue_t & this) with (this) {
    193         verify( 0  == lanes.count );
     198        verify( 4  == lanes.count );
    194199        verify( !query( snzi ) );
     200
     201        ^(snzi){};
     202
     203        for( i; 4 ) {
     204                ^(lanes.data[i]){};
     205        }
    195206        free(lanes.data);
    196207}
     
    484495}
    485496
    486 #warning remove when alloc is fixed
    487 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 
    501497// Grow the ready queue
    502498void ready_queue_grow  (struct cluster * cltr) {
     
    517513
    518514                // Allocate new array (uses realloc and memcpies the data)
    519                 lanes.data = correct_alloc(lanes.data, ncount);
     515                lanes.data = alloc(lanes.data, ncount);
    520516
    521517                // Fix the moved data
     
    562558                size_t ocount = lanes.count;
    563559                // 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");
    565561
    566562                // reduce the actual count so push doesn't use the old queues
     
    604600
    605601                // 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);
    607603
    608604                // Fix the moved data
Note: See TracChangeset for help on using the changeset viewer.