Documentation ¶
Index ¶
- Variables
- type Queue
- func (q *Queue) Close()
- func (q *Queue) CommitToken(t Token) error
- func (q *Queue) EnableDisableTokens(amount int) bool
- func (q *Queue) GetAvailableToken(ctx context.Context) (Token, error)
- func (q *Queue) GetAvailableTokenChan(ctx context.Context) <-chan (Token)
- func (q *Queue) GetCommittedToken(ctx context.Context) (Token, error)
- func (q *Queue) GetCommittedTokenChan(ctx context.Context) <-chan (Token)
- func (q *Queue) ReleaseToken(t Token) error
- type Token
- type TokenFactory
Constants ¶
This section is empty.
Variables ¶
var ( //ErrorClosed is returned when the queue has been closed ErrorClosed = errors.New("Queue has been closed") )
Functions ¶
This section is empty.
Types ¶
type Queue ¶
Queue is a type of queue that allows requesting token (for example command slots) and passing them to a processor that can return them after the command has been completed
func NewQueue ¶
func NewQueue(maximumCapacity int, initialCapacity int, factory TokenFactory) *Queue
NewQueue creates the tokenqueue with a given maximum capacity, initial capacity and factory
func (*Queue) CommitToken ¶
CommitToken takes a token returned by GetAvailableToken and commits it after preparing
func (*Queue) EnableDisableTokens ¶
EnableDisableTokens is used to temporary change the amount of tokens that are available Returns true if the update is possible, false if not. Eg. the BLE HCI command queue is dynamic
func (*Queue) GetAvailableToken ¶
GetAvailableToken will return a token for a free slot to the client
func (*Queue) GetAvailableTokenChan ¶
GetAvailableTokenChan returns a channel from which available tokens can be read
func (*Queue) GetCommittedToken ¶
GetCommittedToken will return a committed token to the processor
func (*Queue) GetCommittedTokenChan ¶
GetCommittedTokenChan returns a channel from which committed tokens can be read
func (*Queue) ReleaseToken ¶
ReleaseToken takes a token returned by GetCommittedToken and releases it after processing
type Token ¶
type Token interface {
Cleanup()
}
Token is an interface that a token should implement. The cleanup method is called upon closing the queue
type TokenFactory ¶
type TokenFactory func() Token
TokenFactory is a function that is called when creating a queue. It should return pointers to tokens