|
Thrill
0.1
|
A virtual Dispatcher which waits for messages to arrive in the mock network.
It is implemented as a ConcurrentBoundedQueue, into which Connections lay notification events.
Inheritance diagram for Dispatcher:
Collaboration diagram for Dispatcher:#include <group.hpp>
Public Types | |
| using | Callback = AsyncCallback |
| type for file descriptor readiness callbacks More... | |
Public Member Functions | |
| Dispatcher () | |
| ~Dispatcher () | |
| virtual destructor More... | |
Implementation of Virtual Methods | |
| void | AddRead (net::Connection &_c, const Callback &read_cb) final |
| Register a buffered read callback and a default exception callback. More... | |
| void | AddWrite (net::Connection &_c, const Callback &write_cb) final |
| Register a buffered write callback and a default exception callback. More... | |
| void | Cancel (net::Connection &) final |
| Cancel all callbacks on a given connection. More... | |
| void | Notify (Connection *c) |
| void | Interrupt () final |
| Interrupt current dispatch. More... | |
| void | DispatchOne (const std::chrono::milliseconds &timeout) final |
Public Member Functions inherited from Dispatcher | |
| Dispatcher ()=default | |
| default constructor More... | |
| Dispatcher (const Dispatcher &)=delete | |
| non-copyable: delete copy-constructor More... | |
| Dispatcher & | operator= (const Dispatcher &)=delete |
| non-copyable: delete assignment operator More... | |
| void | AddTimer (const std::chrono::milliseconds &timeout, const TimerCallback &cb) |
| Register a relative timeout callback. More... | |
| virtual void | AsyncRead (Connection &c, uint32_t, size_t size, const AsyncReadBufferCallback &done_cb) |
| asynchronously read n bytes and deliver them to the callback More... | |
| virtual void | AsyncRead (Connection &c, uint32_t, size_t size, data::PinnedByteBlockPtr &&block, const AsyncReadByteBlockCallback &done_cb) |
| asynchronously read the full ByteBlock and deliver it to the callback More... | |
| virtual void | AsyncWrite (Connection &c, uint32_t, Buffer &&buffer, const AsyncWriteCallback &done_cb=AsyncWriteCallback()) |
| virtual void | AsyncWrite (Connection &c, uint32_t, data::PinnedBlock &&block, const AsyncWriteCallback &done_cb=AsyncWriteCallback()) |
| void | AsyncWriteCopy (Connection &c, uint32_t seq, const void *buffer, size_t size, const AsyncWriteCallback &done_cb=AsyncWriteCallback()) |
| void | AsyncWriteCopy (Connection &c, uint32_t seq, const std::string &str, const AsyncWriteCallback &done_cb=AsyncWriteCallback()) |
| void | Dispatch () |
| Dispatch one or more events. More... | |
| void | Loop () |
| Loop over Dispatch() until terminate_ flag is set. More... | |
| void | Terminate () |
| bool | HasAsyncWrites () const |
| Check whether there are still AsyncWrite()s in the queue. More... | |
Private Member Functions | |
| Watch & | GetWatch (Connection *c) |
| lookup method More... | |
Private Attributes | |
| std::unique_ptr< Data > | d_ |
| pimpl data struct with complex components More... | |
Static Private Attributes | |
| static constexpr bool | debug = false |
Additional Inherited Members | |
Protected Types inherited from Dispatcher | |
| using | TimerPQ = std::priority_queue< Timer, std::vector< Timer, mem::GPoolAllocator< Timer > > > |
| priority queue of timer callbacks More... | |
Static Protected Member Functions inherited from Dispatcher | |
| static bool | ExceptionCallback (Connection &c) |
| Default exception handler. More... | |
Protected Attributes inherited from Dispatcher | |
| std::deque< AsyncReadBuffer, mem::GPoolAllocator< AsyncReadBuffer > > | async_read_ |
| deque of asynchronous readers More... | |
| std::deque< AsyncReadByteBlock, mem::GPoolAllocator< AsyncReadByteBlock > > | async_read_block_ |
| deque of asynchronous readers More... | |
| std::deque< AsyncWriteBuffer, mem::GPoolAllocator< AsyncWriteBuffer > > | async_write_ |
| deque of asynchronous writers More... | |
| std::deque< AsyncWriteBlock, mem::GPoolAllocator< AsyncWriteBlock > > | async_write_block_ |
| deque of asynchronous writers More... | |
| std::atomic< bool > | terminate_ { false } |
| true if dispatcher needs to stop More... | |
| TimerPQ | timer_pq_ |
| using Callback = AsyncCallback |
| Dispatcher | ( | ) |
|
virtual |
|
finalvirtual |
Register a buffered read callback and a default exception callback.
Implements Dispatcher.
Definition at line 236 of file group.cpp.
References Connection::d_, Dispatcher::d_, Dispatcher::GetWatch(), and Dispatcher::Notify().
|
finalvirtual |
Register a buffered write callback and a default exception callback.
Implements Dispatcher.
Definition at line 253 of file group.cpp.
References Connection::d_, Dispatcher::d_, Dispatcher::GetWatch(), and Dispatcher::Notify().
|
finalvirtual |
Cancel all callbacks on a given connection.
Implements Dispatcher.
|
finalvirtual |
Implements Dispatcher.
Definition at line 288 of file group.cpp.
References Connection::d_, Dispatcher::d_, LOG1, and sLOG.
|
private |
lookup method
Definition at line 281 of file group.cpp.
References Dispatcher::d_.
Referenced by Dispatcher::AddRead(), and Dispatcher::AddWrite().
|
finalvirtual |
Interrupt current dispatch.
Implements Dispatcher.
Definition at line 277 of file group.cpp.
References Dispatcher::Notify().
| void Notify | ( | Connection * | c | ) |
Definition at line 273 of file group.cpp.
References Dispatcher::d_.
Referenced by Dispatcher::AddRead(), Dispatcher::AddWrite(), Connection::InboundMsg(), and Dispatcher::Interrupt().
|
private |
pimpl data struct with complex components
Definition at line 201 of file group.hpp.
Referenced by Dispatcher::AddRead(), Dispatcher::AddWrite(), Dispatcher::DispatchOne(), Dispatcher::GetWatch(), and Dispatcher::Notify().