Changeset 16fd826 for libcfa/src


Ignore:
Timestamp:
May 13, 2021, 3:44:19 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
fb4ccdf
Parents:
8cd40bf
Message:

Added count to the ready sub_queues

File:
1 edited

Legend:

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

    r8cd40bf r16fd826  
    1111        // spin lock protecting the queue
    1212        volatile bool lock;
     13
     14        #if !defined(__CFA_NO_STATISTICS__)
     15                unsigned cnt;
     16        #endif
    1317
    1418        __thread_desc_link anchor;
     
    2933        this.anchor.next = 0p;
    3034        this.anchor.ts   = 0;
     35        #if !defined(__CFA_NO_STATISTICS__)
     36                this.cnt  = 0;
     37        #endif
    3138
    3239        // We add a boat-load of assertions here because the anchor code is very fragile
     40        /* paranoid */ _Static_assert( offsetof( $thread, link ) == offsetof(__intrusive_lane_t, anchor) );
    3341        /* paranoid */ verify( offsetof( $thread, link ) == offsetof(__intrusive_lane_t, anchor) );
    3442        /* paranoid */ verify( ((uintptr_t)( mock_head(this) ) + offsetof( $thread, link )) == (uintptr_t)(&this.anchor) );
     
    5462// returns true of lane was empty before push, false otherwise
    5563static inline void push( __intrusive_lane_t & this, $thread * node ) {
     64        /* paranoid */ verify( this.lock );
    5665        /* paranoid */ verify( node->link.next == 0p );
    5766        /* paranoid */ verify( node->link.ts   == 0  );
     
    7281        this.prev->link.ts   = rdtscl();
    7382        this.prev = node;
     83        #if !defined(__CFA_NO_STATISTICS__)
     84                this.cnt++;
     85        #endif
    7486}
    7587
     
    7890// returns true of lane was empty before push, false otherwise
    7991static inline [* $thread, unsigned long long] pop( __intrusive_lane_t & this ) {
     92        /* paranoid */ verify( this.lock );
    8093        /* paranoid */ verify( this.anchor.next != 0p );
    8194        /* paranoid */ verify( this.anchor.ts   != 0  );
     
    89102        node->link.next = 0p;
    90103        node->link.ts   = 0;
     104        #if !defined(__CFA_NO_STATISTICS__)
     105                this.cnt--;
     106        #endif
    91107
    92108        // Update head time stamp
Note: See TracChangeset for help on using the changeset viewer.