- File:
-
- 1 edited
-
libcfa/src/concurrency/ready_subqueue.hfa (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/ready_subqueue.hfa
re71e94a rcf78319 3 3 #define __CFA_NO_SCHED_STATS__ 4 4 5 #include " limits.hfa"5 #include "containers/queueLockFree.hfa" 6 6 7 7 // Intrusives lanes which are used by the relaxed ready queue … … 27 27 } 28 28 29 // Ctor 30 void ?{}( __intrusive_lane_t & this ) { 31 this.lock = false; 32 this.prev = mock_head(this); 33 this.anchor.next = 0p; 34 this.anchor.ts = -1llu; 35 #if !defined(__CFA_NO_STATISTICS__) 36 this.cnt = 0; 37 #endif 38 39 // 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) ); 41 /* paranoid */ verify( offsetof( thread$, link ) == offsetof(__intrusive_lane_t, anchor) ); 42 /* paranoid */ verify( ((uintptr_t)( mock_head(this) ) + offsetof( thread$, link )) == (uintptr_t)(&this.anchor) ); 43 /* paranoid */ verify( &mock_head(this)->link.next == &this.anchor.next ); 44 /* paranoid */ verify( &mock_head(this)->link.ts == &this.anchor.ts ); 45 /* paranoid */ verify( mock_head(this)->link.next == 0p ); 46 /* paranoid */ verify( mock_head(this)->link.ts == -1llu ); 47 /* paranoid */ verify( mock_head(this) == this.prev ); 48 /* paranoid */ verify( __alignof__(__intrusive_lane_t) == 128 ); 49 /* paranoid */ verify( __alignof__(this) == 128 ); 50 /* paranoid */ verifyf( ((intptr_t)(&this) % 128) == 0, "Expected address to be aligned %p %% 128 == %zd", &this, ((intptr_t)(&this) % 128) ); 51 } 52 53 // Dtor is trivial 54 void ^?{}( __intrusive_lane_t & this ) { 55 // Make sure the list is empty 56 /* paranoid */ verify( this.anchor.next == 0p ); 57 /* paranoid */ verify( this.anchor.ts == -1llu ); 58 /* paranoid */ verify( mock_head(this) == this.prev ); 59 } 60 29 61 // Push a thread onto this lane 30 62 // returns true of lane was empty before push, false otherwise … … 32 64 /* paranoid */ verify( this.lock ); 33 65 /* paranoid */ verify( node->link.next == 0p ); 34 /* paranoid */ verify( node->link.ts == MAX);66 /* paranoid */ verify( node->link.ts == -1llu ); 35 67 /* paranoid */ verify( this.prev->link.next == 0p ); 36 /* paranoid */ verify( this.prev->link.ts == MAX);68 /* paranoid */ verify( this.prev->link.ts == -1llu ); 37 69 if( this.anchor.next == 0p ) { 38 70 /* paranoid */ verify( this.anchor.next == 0p ); 39 /* paranoid */ verify( this.anchor.ts == MAX);71 /* paranoid */ verify( this.anchor.ts == -1llu ); 40 72 /* paranoid */ verify( this.anchor.ts != 0 ); 41 73 /* paranoid */ verify( this.prev == mock_head( this ) ); 42 74 } else { 43 75 /* paranoid */ verify( this.anchor.next != 0p ); 44 /* paranoid */ verify( this.anchor.ts != MAX);76 /* paranoid */ verify( this.anchor.ts != -1llu ); 45 77 /* paranoid */ verify( this.anchor.ts != 0 ); 46 78 /* paranoid */ verify( this.prev != mock_head( this ) ); … … 62 94 /* paranoid */ verify( this.lock ); 63 95 /* paranoid */ verify( this.anchor.next != 0p ); 64 /* paranoid */ verify( this.anchor.ts != MAX);96 /* paranoid */ verify( this.anchor.ts != -1llu ); 65 97 /* paranoid */ verify( this.anchor.ts != 0 ); 66 98 … … 71 103 bool is_empty = this.anchor.next == 0p; 72 104 node->link.next = 0p; 73 node->link.ts = MAX;105 node->link.ts = -1llu; 74 106 #if !defined(__CFA_NO_STATISTICS__) 75 107 this.cnt--; … … 80 112 81 113 /* paranoid */ verify( node->link.next == 0p ); 82 /* paranoid */ verify( node->link.ts == MAX);114 /* paranoid */ verify( node->link.ts == -1llu ); 83 115 /* paranoid */ verify( node->link.ts != 0 ); 84 116 /* paranoid */ verify( this.anchor.ts != 0 );
Note:
See TracChangeset
for help on using the changeset viewer.