Documentation
¶
Index ¶
Constants ¶
const ( // Amount of time to delay semaphore acquisition loops. MailboxDelaySleep time.Duration = 50 * time.Millisecond DefaultCtxDeadline time.Duration = 5 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
Custom error structure.
This is compatible with the `error` interface and provides `Unwrap` support.
func NewErrorAndLog ¶
Create a new error object and immediately log it.
func (*Error) MarshalJSON ¶
Convert the error to a JSON string.
type Mailbox ¶
type Mailbox struct {
// contains filtered or unexported fields
}
Mailbox structure.
This is a cheap implementation of a mailbox.
It uses two semaphores to control read and write access, and contains a single datum.
This is *not* a queue!
func NewMailbox ¶
func NewMailbox() *Mailbox
Create and return a new empty mailbox.
Note: this acquires the `preventRead` semaphore.
func (*Mailbox) Get ¶
Get an element from the mailbox. Defaults to using a context with a deadline of 5 seconds.
func (*Mailbox) GetWithContext ¶
type Pair ¶
type Pair struct {
First interface{}
Second interface{}
}
Pair structure.
This is a cheap implementation of a pair (aka two-value tuple).
I wish generics were a thing.