15 #ifndef THRILL_NET_DISPATCHER_THREAD_HEADER 16 #define THRILL_NET_DISPATCHER_THREAD_HEADER 50 void (
Connection&), mem::GPoolAllocator<char> >;
62 static constexpr
bool debug =
false;
69 std::unique_ptr<class Dispatcher> dispatcher,
135 Connection& c, uint32_t seq,
const void* buffer,
size_t size,
181 #endif // !THRILL_NET_DISPATCHER_THREAD_HEADER DispatcherThread(std::unique_ptr< class Dispatcher > dispatcher, size_t host_rank)
void Work()
What happens in the dispatcher thread.
void AddWrite(Connection &c, const AsyncCallback &write_cb)
Register a buffered write callback and a default exception callback.
tlx::delegate< void(Connection &), mem::GPoolAllocator< char > > AsyncWriteCallback
Signature of async write callbacks.
void WakeUpThread()
wake up select() in dispatching thread.
std::unique_ptr< class Dispatcher > dispatcher_
enclosed dispatcher.
A pinned / pin-counted pointer to a ByteBlock.
tlx::delegate< bool(), mem::GPoolAllocator< char > > AsyncCallback
Signature of async connection readability/writability callbacks.
static constexpr bool debug
DispatcherThread & operator=(const DispatcherThread &)=delete
non-copyable: delete assignment operator
void AddTimer(std::chrono::milliseconds timeout, const TimerCallback &cb)
Register a relative timeout callback.
std::atomic< bool > terminate_
termination flag
void Terminate()
Terminate the dispatcher thread (if now already done).
This is a queue, similar to std::queue and tbb::concurrent_queue, except that it uses mutexes for syn...
void AsyncRead(Connection &c, uint32_t seq, size_t size, const AsyncReadCallback &done_cb)
asynchronously read n bytes and deliver them to the callback
A Connection represents a link to another peer in a network group.
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
void AsyncWriteCopy(Connection &c, uint32_t seq, const void *buffer, size_t size, const AsyncWriteCallback &done_cb=AsyncWriteCallback())
tlx::delegate< bool(), mem::GPoolAllocator< char > > TimerCallback
Signature of timer callbacks.
void Cancel(Connection &c)
Cancel all callbacks on a given connection.
void AsyncWrite(Connection &c, uint32_t seq, Buffer &&buffer, const AsyncWriteCallback &done_cb=AsyncWriteCallback())
A pinned / pin-counted derivative of a Block.
void AddRead(Connection &c, const AsyncCallback &read_cb)
Register a buffered read callback and a default exception callback.
Simple buffer of characters without initialization or growing functionality.
size_t host_rank_
for thread name for logging
std::atomic< bool > busy_
whether to call Interrupt() in WakeUpThread()
void Enqueue(Job &&job)
Enqueue job in queue for dispatching thread to run at its discretion.
common::ConcurrentQueue< Job, mem::GPoolAllocator< Job > > jobqueue_
Queue of jobs to be run by dispatching thread at its discretion.
Dispatcher is a high level wrapper for asynchronous callback processing.
void RunInThread(const AsyncDispatcherThreadCallback &cb)
Run generic callback in dispatcher thread to enqueue stuff.
tlx::delegate< void(Connection &c, Buffer &&buffer), mem::GPoolAllocator< char > > AsyncReadCallback
Signature of async read callbacks.
std::thread thread_
thread of dispatcher
DispatcherThread contains a net::Dispatcher object and an associated thread that runs in the dispatch...