CAF  0.17.3
Classes | Public Member Functions | List of all members
caf::credit_controller Class Referenceabstract

Computes credit for an attached source. More...

#include <credit_controller.hpp>

Inheritance diagram for caf::credit_controller:
caf::detail::complexity_based_credit_controller caf::detail::size_based_credit_controller caf::detail::test_credit_controller

Classes

struct  assignment
 Wraps an assignment of the controller to its source. More...
 

Public Member Functions

 credit_controller (scheduled_actor *self)
 
scheduled_actorself () noexcept
 
virtual void before_processing (downstream_msg::batch &x)=0
 Called before processing the batch x in order to allow the controller to keep statistics on incoming batches.
 
virtual void after_processing (downstream_msg::batch &x)=0
 Called after processing the batch x in order to allow the controller to keep statistics on incoming batches. More...
 
virtual assignment compute_initial ()=0
 Assigns initial credit during the stream handshake. More...
 
virtual assignment compute (timespan cycle, int32_t max_downstream_credit)=0
 Assigs new credit to the source after a cycle ends. More...
 
virtual assignment compute_bridge ()
 Computes a credit assignment to the source after crossing the low-threshold. More...
 
virtual int32_t threshold () const noexcept
 Returns the threshold for when we may give extra credit to a source during a cycle. More...
 

Detailed Description

Computes credit for an attached source.

Member Function Documentation

◆ after_processing()

virtual void caf::credit_controller::after_processing ( downstream_msg::batch x)
pure virtual

Called after processing the batch x in order to allow the controller to keep statistics on incoming batches.

Note
The consumer may alter the batch while processing it, for example by moving each element of the batch downstream.

Implemented in caf::detail::complexity_based_credit_controller, caf::detail::test_credit_controller, and caf::detail::size_based_credit_controller.

◆ compute()

virtual assignment caf::credit_controller::compute ( timespan  cycle,
int32_t  max_downstream_credit 
)
pure virtual

Assigs new credit to the source after a cycle ends.

Parameters
cycleDuration of a cycle.
max_downstream_creditMaximum downstream capacity as reported by the downstream manager. Controllers may use this capacity as an upper bound.

Implemented in caf::detail::complexity_based_credit_controller, caf::detail::test_credit_controller, and caf::detail::size_based_credit_controller.

◆ compute_bridge()

virtual assignment caf::credit_controller::compute_bridge ( )
virtual

Computes a credit assignment to the source after crossing the low-threshold.

May assign zero credit.

Reimplemented in caf::detail::size_based_credit_controller.

◆ compute_initial()

virtual assignment caf::credit_controller::compute_initial ( )
pure virtual

Assigns initial credit during the stream handshake.

Returns
The initial credit for the new sources.

Implemented in caf::detail::complexity_based_credit_controller, caf::detail::test_credit_controller, and caf::detail::size_based_credit_controller.

◆ threshold()

virtual int32_t caf::credit_controller::threshold ( ) const
virtualnoexcept

Returns the threshold for when we may give extra credit to a source during a cycle.

Returns
Zero or a negative value if the controller never grants bridge credit, otherwise the threshold for calling compute_bridge to generate additional credit.

Reimplemented in caf::detail::size_based_credit_controller.


The documentation for this class was generated from the following file: