Accepts and reads the inbound connections of an actor system on an I/O thread. More...
#include <threaded_inbound.hpp>
Public Types | |
| using | TSocket = typename TPoller::TSocket |
Public Member Functions | |
| TThreadedInbound (TPoller &poller, TSocket listener, TNodeId nodeId, TDelivery &delivery, std::function< void(const std::string &)> logger={}) | |
| TThreadedInbound (TPoller &poller, TSocket listener, TNodeId nodeId, TDelivery &delivery, const TMessagesFactory &factory, std::function< void(const std::string &)> logger={}) | |
| ~TThreadedInbound () | |
| Destroys the coroutines first: they wait on the sockets. | |
| TThreadedInbound (const TThreadedInbound &)=delete | |
| TThreadedInbound & | operator= (const TThreadedInbound &)=delete |
| size_t | Connections () const |
| Connections accepted and not forgotten yet. On the I/O thread, or while its loop does not run. | |
Accepts and reads the inbound connections of an actor system on an I/O thread.
The accept loop and one coroutine per connection run on poller, which belongs to another thread (see TLoopThread). A connection reads its socket into its own TEnvelopeReader, as a connection of TActorSystem::Serve(TSocket) does, and hands the envelopes of every read to delivery in one TEnvelopeBatch. Envelopes for another node are dropped and logged, as there.
With a factory, the payloads of the types registered with TMessagesFactory::RegisterDeserializer are deserialized here, on the I/O thread: the actors get Near blobs of them, all other envelopes go on unchanged. An envelope whose deserializer throws is dropped and logged. The bytes counted against the limit of the delivery are those read.
TDelivery is the way to the actors; TQueuedDelivery is the one for an actor system on another thread. Both calls are made on the I/O thread:
A finished connection closes its socket; the inbound forgets it at the next accept.
| TPoller | Poller type of the I/O thread; determines the socket type. |
| TDelivery | Receives the batches, see above. |
| TEnvelopeReader | TZeroCopyEnvelopeReader, which copies every payload into an allocation of its own, or TZeroCopyEnvelopeReaderV2, whose payloads point into its chunks and may be released on any thread. |
|
inline |
| poller | Poller of the I/O thread. |
| listener | Bound, listening socket on poller. |
| nodeId | Node of the actor system: envelopes for other nodes are dropped. |
| delivery | Receives the envelopes; outlives the inbound. |
| logger | Optional; called on the I/O thread. |
|
inline |
The same, and the payloads of the types factory can deserialize are deserialized on the I/O thread. factory outlives the inbound.