Skip to content

Commit

Permalink
"Inline" the Atomic.t objects into the next fields of nodes
Browse files Browse the repository at this point in the history
This effectively halves the length of the linked list of nodes and roughly
doubles the thruput of the queue.
  • Loading branch information
polytypic committed Apr 2, 2024
1 parent d4d5c0b commit bd8eae0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src_lockfree/michael_scott_queue_node.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ module Atomic = Transparent_atomic
type ('a, _) t =
| Nil : ('a, [> `Nil ]) t
| Next : {
next : ('a, [ `Nil | `Next ]) t Atomic.t;
mutable next : ('a, [ `Nil | `Next ]) t;
mutable value : 'a;
}
-> ('a, [> `Next ]) t

let[@inline] make value = Next { next = Atomic.make Nil; value }
let[@inline] as_atomic (Next r : ('a, [ `Next ]) t) = r.next
let[@inline] make value = Next { next = Nil; value }

external as_atomic : ('a, [ `Next ]) t -> ('a, [ `Nil | `Next ]) t Atomic.t
= "%identity"

0 comments on commit bd8eae0

Please sign in to comment.