Documentation
¶
Overview ¶
Package asm provides architecture-specific helpers for hot paths.
Layout contract: The SPSCIndirect offsets used by assembly must match the Go struct layout. The expected offsets are verified by tests on supported architectures.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SPSCDequeue ¶
SPSCDequeue performs an optimized SPSC dequeue operation. Combines cached index check, buffer load, and head update.
Returns:
- elem: the dequeued value (valid only if err == 0)
- err: 0 on success, 1 if queue is empty (ErrWouldBlock)
func SPSCEnqueue ¶
SPSCEnqueue performs an optimized SPSC enqueue operation. It combines the cached index check, buffer store, and tail update in a tight instruction sequence without Go runtime preemption points.
Parameters (passed via registers per Go ABI):
- q: pointer to SPSCIndirect struct
- elem: the uintptr value to enqueue
Returns:
- 0 on success
- 1 if queue is full (ErrWouldBlock)
The struct layout is (verified via reflection):
- offset 0: pad (64 bytes cache line isolation)
- offset 64: head (atomix.Uint64 - 8 bytes)
- offset 72: pad (64 bytes)
- offset 136: cachedTail (8 bytes, non-atomic)
- offset 144: pad (64 bytes)
- offset 208: tail (atomix.Uint64 - 8 bytes)
- offset 216: pad (64 bytes)
- offset 280: cachedHead (8 bytes, non-atomic)
- offset 288: pad (64 bytes)
- offset 352: buffer (slice header: ptr, len, cap = 24 bytes)
- offset 376: mask (8 bytes)
- Total size: 384 bytes
Types ¶
This section is empty.