Changeset 0f89d4f for libcfa


Ignore:
Timestamp:
Jun 19, 2020, 5:30:16 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
b232745
Parents:
68f36f4
Message:

Modified StackLF to use `next instead of getNext

Location:
libcfa/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel.hfa

    r68f36f4 r0f89d4f  
    118118static inline void  ?{}(processor & this, const char name[]) { this{name, *mainCluster }; }
    119119
    120 static inline Link(processor) * getNext( processor * this ) { return &this->link; }
     120static inline Link(processor) * ?`next( processor * this ) { return &this->link; }
    121121
    122122//-----------------------------------------------------------------------------
  • libcfa/src/containers/stackLockFree.hfa

    r68f36f4 r0f89d4f  
    3131}; // Link
    3232
    33 forall( otype T | { Link(T) * getNext( T * ); } ) {
     33forall( otype T | { Link(T) * ?`next( T * ); } ) {
    3434        struct StackLF {
    3535                Link(T) stack;
     
    4343                void push( StackLF(T) & this, T & n ) with(this) {
    4444                        for () {                                                                        // busy wait
    45                                 *getNext( &n ) = stack;                                 // atomic assignment unnecessary, or use CAA
    46                           if ( __atomic_compare_exchange_n( &stack.atom, &getNext( &n )->atom, (Link(T))@{ {&n, getNext( &n )->count + 1} }.atom, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) ) break; // attempt to update top node
     45                                *( &n )`next = stack;                                   // atomic assignment unnecessary, or use CAA
     46                          if ( __atomic_compare_exchange_n( &stack.atom, &( &n )`next->atom, (Link(T))@{ {&n, ( &n )`next->count + 1} }.atom, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) ) break; // attempt to update top node
    4747                        } // for
    4848                } // push
     
    5353                                t = stack;                                                              // atomic assignment unnecessary, or use CAA
    5454                          if ( t.top == 0p ) return 0p;                         // empty stack ?
    55                           if ( __atomic_compare_exchange_n( &stack.atom, &t.atom, (Link(T))@{ {getNext( t.top )->top, t.count} }.atom, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) ) return t.top; // attempt to update top node
     55                          if ( __atomic_compare_exchange_n( &stack.atom, &t.atom, (Link(T))@{ {( t.top )`next->top, t.count} }.atom, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) ) return t.top; // attempt to update top node
    5656                        } // for
    5757                } // pop
     
    6262                                T * next = link->top;
    6363                                if( next == node ) {
    64                                         link->top = getNext( node )->top;
     64                                        link->top = ( node )`next->top;
    6565                                        return true;
    6666                                }
    6767                                if( next == 0p ) return false;
    68                                 link = getNext(next);
     68                                link = (next)`next;
    6969                        }
    7070                }
  • libcfa/src/heap.cfa

    r68f36f4 r0f89d4f  
    208208
    209209#if BUCKETLOCK == LOCKFREE
    210 static inline Link(HeapManager.Storage) * getNext( HeapManager.Storage * this ) { return &this->header.kind.real.next; }
     210static inline Link(HeapManager.Storage) * ?`next( HeapManager.Storage * this ) { return &this->header.kind.real.next; }
    211211static inline void ?{}( HeapManager.FreeHeader & ) {}
    212212static inline void ^?{}( HeapManager.FreeHeader & ) {}
     
    665665                #else
    666666                for ( HeapManager.Storage * p = top( freeLists[i].freeList ); p != 0p; /* p = getNext( p )->top */) {
    667                         typeof(p) temp = getNext( p )->top;                     // FIX ME: direct assignent fails, initialization works
     667                        typeof(p) temp = ( p )`next->top;                       // FIX ME: direct assignent fails, initialization works
    668668                        p = temp;
    669669                #endif // BUCKETLOCK
     
    901901                        return oaddr;
    902902                } // if
    903        
     903
    904904                // change size, DO NOT preserve STICKY PROPERTIES.
    905905                free( oaddr );
Note: See TracChangeset for help on using the changeset viewer.