COROIO: NNet::NActors::TQueuedDelivery Class Reference
COROIO
Loading...
Searching...
No Matches
NNet::NActors::TQueuedDelivery Class Reference

Delivery of TThreadedInbound to an actor system on another thread. More...

#include <threaded_inbound.hpp>

Public Member Functions

 TQueuedDelivery (TActorSystem &system, size_t limit=DefaultLimit)
 ~TQueuedDelivery ()
 Destroys the coroutine first: it waits on the notifier and pops the queue.
 TQueuedDelivery (const TQueuedDelivery &)=delete
TQueuedDelivery & operator= (const TQueuedDelivery &)=delete
bool Full () const
 I/O side: true while the connections must not read.
void Deliver (std::unique_ptr< TEnvelopeBatch > batch)
 I/O side.
size_t QueuedBytes () const
 Bytes handed over and not passed to Send yet. Any thread.

Static Public Attributes

static constexpr size_t DefaultLimit = 16 * 1024 * 1024

Detailed Description

Delivery of TThreadedInbound to an actor system on another thread.

  • I/O side — Deliver pushes a batch into a TGrowMailbox and wakes the actor side through a notifier of the actor system's poller. Any number of I/O threads may deliver.
  • Actor side — a coroutine on that poller pops the batches and calls TActorSystem::Send for every envelope, in the order of Deliver calls of each thread. After every 2 MiB it lets the loop run its other coroutines and the actors, as the connections of TActorSystem::Serve(TSocket) do.

Full() is true while the bytes handed over and not passed to Send yet reach limit. A connection that it stops looks again only after 1 ms, so limit must hold more than a millisecond of the actor side's work: under backpressure the delivery passes at most about limit per millisecond (16 GB/s with the default, 1 GB/s with 1 MiB).

Note
Construct and destroy it on the thread of the actor system, before its loop runs and after the I/O threads that deliver to it have stopped. The destructor deletes the batches that were not delivered. The actor system outlives it.
Not available on Windows: it needs TNotifier.

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