CreditFlowControl¶
-
class
kanzi::connect
::
CreditFlowControl
¶ Credit based flow control logic for both ends of the link.
Public Functions
-
CreditFlowControl
(int credits = -1, int creditReturnInterval = -1)¶ Constructor.
- Parameters
credits
: the initial amount of credits available.creditReturnInterval
: how often should credits be returned. meaningfull only on client side.
-
void
add
(int amount = 1)¶ Adds a credit, used on both sizes of connection to inform used/received credits.
- Parameters
amount
: the amount of credits bring back.
-
bool
getProductionCredit
()¶ Gets a credit for production, used on producer/sender side.
- Return
true if at least one credit was available or credit system disabled.
-
int
getReturnableCredits
()¶ Retrieves the amount of credits that can be returned.
- Return
the credit amount. 0 if nothing to return at the moment.
-
void
initialize
(int credits, int creditReturnInterval = -1)¶ Initialize the object with provided credit information.
- Parameters
credits
: the initial amount of credits available.creditReturnInterval
: how often should credits be returned. meaningfull only on client side.
-
bool
isEnabled
() const¶ State of credit system.
- Return
true if credit system is enabled.
-
void
restart
()¶ Restores the object into state it had after construction/latest initialize() call.
calling uninitialize() will render restarting impossible.
-
void
uninitialize
()¶ Uninitializes the flow control. isEnabled() will return false after calling this method.
-