loony/spec

Source   Edit  

Types

ControlBlock = object
  headMask*: Atomic[ControlMask] ## high uint16, final observed count of slow-path dequeue ops,
                                 ## low uint16: current count
  tailMask*: Atomic[ControlMask] ## Bitmask for storing current reclamation status
                                 ## All 3 bits set = node can be reclaimed
  reclaim*: Atomic[uint8]
high uint16 final observed count of slow-path enqueue ops low uint16: current count Source   Edit  
ControlMask = uint32
Source   Edit  
NodePtr = uint
Source   Edit  
TagPtr = uint
Aligned pointer with 12 bit prefix containing the tag. Access using procs nptr and idx Source   Edit  

Consts

CONSUMED = 6'u8
Source   Edit  
DEQ = 2'u
Source   Edit  
ENQ = 4'u
Source   Edit  
loonyIsolated {.booldefine.} = false
Indicate that loony should assert that all references passing through the queue have a single owner. Note that in particular, child Continuations have cycles, which will trigger a failure of this assertion. Source   Edit  
loonyNodeAlignment {.intdefine.} = 11
Source   Edit  
loonyRotate {.booldefine.} = true
Indicate that loony should rotate the slots in the queue to avoid contention on the same cache line. This is useful when the queue is shared between multiple threads. Note that this will only work if the number of slots is a power of 2. Source   Edit  
loonySlotCount {.intdefine.} = 1024
Source   Edit  
lShiftBits = 6
Source   Edit  
MASK = 0x0000FFFF
Source   Edit  
N = 1024
Source   Edit  
NODEALIGN: uint = 2048
Source   Edit  
PTRMASK: uint = 18446744073709549568'u
Source   Edit  
READER = 4'u
Source   Edit  
RESUME = 1'u
Source   Edit  
rShiftBits = 4
Source   Edit  
SHIFT = 16
Source   Edit  
SLOT = 1'u
Source   Edit  
SLOTMASK: uint = 18446744073709551608'u
Source   Edit  
TAGBITS: uint = 11
Source   Edit  
TAGMASK: uint = 2047'u
Source   Edit  
UNINIT = 0'u
Source   Edit  
WRITER = 2'u
Source   Edit  

Procs

proc fetchAddHead(ctrl: var ControlBlock; v: uint32 = 1): ControlMask {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc fetchAddReclaim(ctrl: var ControlBlock; v: uint8 = 1): uint8 {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc fetchAddTail(ctrl: var ControlBlock; v: uint32 = 1): ControlMask {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc getHigh(mask: ControlMask): uint16 {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc getLow(mask: ControlMask): uint16 {....raises: [], tags: [], forbids: [].}
Source   Edit