my.actor.utility.limiter

Members

Aliases

FlowControlActor
alias FlowControlActor = typedActor!(Token function(TakeTokenMsg), void function(ReturnTokenMsg), void function(RefreshMsg))
Undocumented in source.

Functions

spawnFlowControl
FlowControlActor.Impl spawnFlowControl(FlowControlActor.Impl self, uint tokens)
Undocumented in source. Be warned that the author may not have intended to support it.
spawnFlowControlTotalCPUs
FlowControlActor.Impl spawnFlowControlTotalCPUs(FlowControlActor.Impl self)

Initialize the flow controller to total cpu's + 1.

Structs

ReturnTokenMsg
struct ReturnTokenMsg

Return a token.

TakeTokenMsg
struct TakeTokenMsg

Take a token if there are any free.

Token
struct Token

A token of work.

Meta

Authors

Joakim Brännström (joakim.brannstrom@gmx.com)

An actor that can limit the flow of messages between consumer/producer.

The limiter is initialized with a number of tokens.

Producers try and take a token from the limiter. Either one is free and they get it right away or a promise is returned. The promise will trigger whenever a token is returned by the consumre. The waiting producers are triggered in LIFO (just because that is a more efficient data structure).

A consumer receiver a message from a producer containing the token and data. When the consumer has finished processing the message it returns the token to the limier.