Documentation ¶
Overview ¶
Spin provides objects for assisting with sleeping while waiting for an action to become available. This is useful in preventing CPU starvation when there is nothing to do.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a FIFO queue. The queue can grow to infinite size and pushing an item will never fail. This value must never be copied once created (in other words, make it a pointer value if shared across func/method boundaries).
func (*Buffer) Close ¶
func (b *Buffer) Close()
Close closes the output channel used in Next() calls. This is only needed if you are using .Next() and not Pop() or Pull().
func (*Buffer) Next ¶
func (b *Buffer) Next() chan interface{}
Next pulls an item from the Buffer until Close() is called. This is nice for for/range loops, but is slightly slower than Pull() and requires a goroutine per Next() call. Note: Do not use Pop/Pull() and Next() together, use one or the other.
func (*Buffer) Pop ¶
Pop pops an item from the Buffer. If an item cannot be returned, it returns ok == false. Note: Do not use Pop() and Next() together, use one or the other. Note: It is safe to use Pop() and Pull() together.