This contains the LoonyQueue object and associated push/pop operations.
There is a detailed explanation of the algorithm operation within the src files if you are having issues or want to contribute.
Types
LoonyQueue[T] = ref LoonyQueueImpl[T]
- Source Edit
LoonyQueueImpl[T] = object ## Whereby node contains the slots and idx ## is the uint16 index of the slot array ## 8 bytes Current NodePtr
- Source Edit
Procs
proc `=destroy`[T](x: var LoonyQueueImpl[T]) {....raises: [].}
- Destroy is completely operated on the basis that no other threads are operating on the queue at the same time. To not follow this will result in SIGSEGVs and undefined behaviour. Source Edit
proc initLoonyQueue(q: LoonyQueue)
- Initialize an existing LoonyQueue. Source Edit
proc initLoonyQueue[T](): LoonyQueue[T] {. ...deprecated: "Use newLoonyQueue instead".}
- Source Edit Return an initialized LoonyQueue.
proc isEmpty(queue: LoonyQueue): bool
- This operation should only be used by internal code. The response for this operation is not precise. Source Edit
proc newLoonyQueue[T](): LoonyQueue[T]
- Return an intialized LoonyQueue. Source Edit
proc pop[T](queue: LoonyQueue[T]): T
-
Remove and return to the caller the next item in the LoonyQueue. This operation ensures some level of cache coherency using atomic thread fences.
Use unsafePop to avoid this cost.
Source Edit proc push[T](queue: LoonyQueue[T]; el: sink T)
-
Push an item onto the end of the LoonyQueue. This operation ensures some level of cache coherency using atomic thread fences.
Use unsafePush to avoid this cost.
Source Edit proc toStrTuple(tag: TagPtr): string {....raises: [], tags: [], forbids: [].}
- Source Edit
proc unsafePop[T](queue: LoonyQueue[T]): T
- Remove and return to the caller the next item in the LoonyQueue. Unlike pop, this operation does not use atomic thread fences. This means you may get undefined behaviour if the caller has old cached memory that is related to the item. Source Edit
proc unsafePush[T](queue: LoonyQueue[T]; el: sink T)
- Push an item onto the end of the LoonyQueue. Unlike push, this operation does not use atomic thread fences. This means you may get undefined behaviour if the receiving thread has old cached memory related to this element Source Edit