- Timestamp:
- Apr 15, 2021, 1:08:16 PM (2 years ago)
- Branches:
- ADT, arm-eh, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 200a229, 76c94bf
- Parents:
- 8590328
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/thierry_delisle_PhD/code/readyQ_proto/links2.hpp
r8590328 r780a614 56 56 template<typename node_t> 57 57 class mpsc_queue : private mcs_queue<node_t> { 58 node_t * volatile head;58 node_t * volatile _head; 59 59 public: 60 mpsc_queue(): mcs_queue<node_t>(), head(nullptr) {}60 mpsc_queue(): mcs_queue<node_t>(), _head(nullptr) {} 61 61 62 62 inline bool empty() const { return mcs_queue<node_t>::empty(); } 63 64 node_t * head() const { return _head; } 63 65 64 66 // Added a new element to the queue … … 66 68 inline node_t * push(node_t * elem) { 67 69 node_t * prev = mcs_queue<node_t>::push(elem); 68 if (!prev) head = elem;70 if (!prev) _head = elem; 69 71 return prev; 70 72 } … … 75 77 // NOT Multi-Thread Safe 76 78 inline node_t * pop(node_t *& next) { 77 node_t * elem = head;79 node_t * elem = _head; 78 80 // If head is empty just return 79 81 if (!elem) return nullptr; … … 81 83 // If there is already someone in the list, then it's easy 82 84 if (elem->_links.next) { 83 head = next = elem->_links.next;85 _head = next = elem->_links.next; 84 86 // force memory sync 85 87 __atomic_thread_fence(__ATOMIC_SEQ_CST); … … 93 95 // at the CAS in advance and therefore can write to head 94 96 // after that point, it could overwrite the write in push 95 head = nullptr;97 _head = nullptr; 96 98 next = mcs_queue<node_t>::advance(elem); 97 99 … … 99 101 // it is the only way we can guarantee we are not overwriting 100 102 // a write made in push 101 if (next) head = next;103 if (next) _head = next; 102 104 } 103 105
Note: See TracChangeset
for help on using the changeset viewer.