79 |
|
* Overview: The core algorithm is, for an exchange "slot", |
80 |
|
* and a participant (caller) with an item: |
81 |
|
* |
82 |
< |
* for (;;) { |
83 |
< |
* if (slot is empty) { // offer |
84 |
< |
* place item in a Node; |
85 |
< |
* if (can CAS slot from empty to node) { |
86 |
< |
* wait for release; |
87 |
< |
* return matching item in node; |
88 |
< |
* } |
89 |
< |
* } |
90 |
< |
* else if (can CAS slot from node to empty) { // release |
91 |
< |
* get the item in node; |
92 |
< |
* set matching item in node; |
93 |
< |
* release waiting thread; |
82 |
> |
* for (;;) { |
83 |
> |
* if (slot is empty) { // offer |
84 |
> |
* place item in a Node; |
85 |
> |
* if (can CAS slot from empty to node) { |
86 |
> |
* wait for release; |
87 |
> |
* return matching item in node; |
88 |
|
* } |
89 |
< |
* // else retry on CAS failure |
90 |
< |
* } |
89 |
> |
* } |
90 |
> |
* else if (can CAS slot from node to empty) { // release |
91 |
> |
* get the item in node; |
92 |
> |
* set matching item in node; |
93 |
> |
* release waiting thread; |
94 |
> |
* } |
95 |
> |
* // else retry on CAS failure |
96 |
> |
* } |
97 |
|
* |
98 |
|
* This is among the simplest forms of a "dual data structure" -- |
99 |
|
* see Scott and Scherer's DISC 04 paper and |