Documentation
¶
Overview ¶
Package syncs provides synchronization primitives.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group is a sync.WaitGroup with a Go method.
func (*Group) Running ¶
Running returns the number of goroutines that are currently running.
If a call to [Running] returns zero, and a call to [Wait] is made without any calls to [Go], then [Wait] will return immediately. This is true even if a goroutine is started and finishes between the two calls.
It is possible for [Running] to return non-zero and for [Wait] to return immediately. This can happen if the all running goroutines finish between the two calls.
type Line ¶
type Line struct {
// contains filtered or unexported fields
}
Line is an ordered sequence of tickets waiting for their turn to proceed.
To get a ticket use Line.Take. To signal that a ticket is done use Ticket.Done. To wait your turn use Ticket.Ready.
A Line is not safe for concurrent use.
type RelayReader ¶
type RelayReader struct {
// contains filtered or unexported fields
}
RelayReader implements an io.WriterTo that yields the passed writer to its [WriteTo] method each io.WriteCloser taken from [Take], in the order they are taken. Each io.WriteCloser blocks until the previous one is closed, or a call to RelayReader.CloseWithError is made.
The zero value is invalid. Use [NewWriteToLine] to get a valid RelayReader.
It is not safe for concurrent use.
func NewRelayReader ¶
func NewRelayReader() *RelayReader
func (*RelayReader) Close ¶
func (q *RelayReader) Close() error
Close closes the line. Any writer waiting for its turn will be unblocked with an io.ErrClosedPipe error.
It never returns an error.
func (*RelayReader) CloseWithError ¶
func (q *RelayReader) CloseWithError(err error) error
CloseWithError terminates the line, unblocking any writer waiting for its turn with the error, or io.EOF if err is nil. It is safe to call [CloseWithError] multiple times and across multiple goroutines.
If the line is already closed, [CloseWithError] is a no-op.
It never returns an error.
func (*RelayReader) Take ¶
func (q *RelayReader) Take() io.WriteCloser
Take returns a writer that will be passed to the next writer in line.
It is not safe for use across multiple goroutines.
type Ticket ¶
type Ticket struct {
// contains filtered or unexported fields
}
Ticket represents a ticket in a sequence of tickets. The zero value is invalid. Use Line.Take to get a valid ticket.
A Ticket is not safe for concurrent use.