Discover Packages
capnproto.org/go/capnp/v3
exp
spsc
package
Version:
v3.0.0-alpha.11
Opens a new window with list of versions in this module.
Published: Dec 6, 2022
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
Documentation
¶
Package spsc implements a single-producer, single-consumer queue.
type Queue[T any ] struct {
Tx [T]
Rx [T]
}
A single-producer, single-consumer queue. Create one with New(),
and send with Tx.Send(). Tx and Rx are each not safe for use by
multiple goroutines, but two separate goroutines can use Tx and
Rx respectively.
Create a new, initially empty Queue.
type Rx[T any ] struct {
}
The receive end of a Queue.
Receive a message from the queue. Blocks if the queue is empty.
If the context ends before the receive happens, this returns
ctx.Err().
func (rx *Rx [T]) TryRecv() (v T, ok bool )
Try to receive a message from the queue. If successful, ok will be true.
If the queue is empty, this will return immediately with ok = false.
type Tx[T any ] struct {
}
The send/transmit end of a Queue.
func (tx *Tx [T]) Send(v T)
Send a message on the queue.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.