ConcurrentQueue
Parameters
[DType, AddMutex = Nil, PopMutex = Nil; block_size = 64]
This is a high performance concurrent queue that internally uses a circular linked list of ring buffers to store the items. Concurrent add
and pop
to and from this queue only take a few nano seconds on modern hardware. You can concurrently add and pop items from different threads. In addition you can choose to install mutexes for add
and pop
operations separately to enable adding and removing items from more than one thread each.
Type parameters:
- DType type of the item in the queue
- AddMutex The mutex to use for the add method (is Nil by default).
- PopMutex The mutex to use for the pop method (is Nil by default).
const expression params:
- block_size the size of each circular buffer.
graph BT
N1["ConcurrentQueue[DType,AddMutex,PopMutex; block_size]"] -->|inherits| N2["Length"];
Characteristics
Quality | Value |
---|---|
Inherits | Length |
Extends | N/A |
Decorators | #sealed; #Gambol.layout.c; |
Is enum | false |
Is sealed | true |
Is extern | false |
Const Expressions
kMinBlocks
const! kMinBlocks = 4 NInt
Methods
construct
construct (s Self) -> Self
add
add (s Self, item @DType) -> Nil
pop_wait_for
pop_wait_for (s Self, wait_for Time) -> DType?
pop_wait_until
pop_wait_until (s Self, wait_until Time) -> DType?
pop
pop (s Self, blocking Bool = true) -> DType?
len
#strict
len (s Self) -> Len
peek
peek (s Self) -> @DType?
__inner_add
__inner_add (s Self, item @DType) -> Nil
__inner_pop
__inner_pop (s Self, result_ptr PointerToVariable[DType?]) -> Bool
Properties
__tail_block
__tail_block Pointer
__empty1
__empty1 Int512
__head_block
__head_block Pointer
__empty2
__empty2 Int512
__block_type_ptr
__block_type_ptr PointerToTypeDefinition[QueueBlock__[DType, block_size]]
__free_blocks
__free_blocks NInt
__used_blocks
__used_blocks NInt
__sem
__sem Semaphore
__empty3
__empty3 Int512
__add_mutex
__add_mutex AddMutex
__empty4
__empty4 Int512
__pop_mutex
__pop_mutex PopMutex