29 for (
int fd = 3; fd < static_cast<int>(
watch_.size()); ++fd) {
41 std::ostringstream oss;
44 for (
int fd = 3; fd < static_cast<int>(
watch_.size()); ++fd) {
50 oss <<
"r" << fd <<
" ";
52 oss <<
"w" << fd <<
" ";
54 oss <<
"e" << fd <<
" ";
57 LOG <<
"Performing select() on " << oss.str();
60 int r = fdset.
select_timeout(static_cast<double>(timeout.count()));
65 LOG <<
"Dispatch(): select() was interrupted due to a signal.";
69 throw Exception(
"Dispatch::Select() failed!", errno);
76 for (
int fd = 3; fd < static_cast<int>(
watch_.size()); ++fd)
110 LOG <<
"SelectDispatcher: got read event for fd " 111 << fd <<
" without a read handler.";
142 LOG <<
"SelectDispatcher: got write event for fd " 143 << fd <<
" without a write handler.";
176 while ((wb = write(
self_pipe_[1],
this, 1)) == 0) {
177 LOG1 <<
"WakeUp: error sending to self-pipe: " << errno;
void Interrupt() final
Interrupt the current select via self-pipe.
Select & ClearException(int fd)
Clear a file descriptor from the exception set.
bool InException(int fd) const
Check if a file descriptor is in the resulting exception set.
bool InWrite(int fd) const
Check if a file descriptor is in the resulting Write set.
Select & ClearWrite(int fd)
Clear a file descriptor from the write set.
Callback except_cb
only one exception callback for the fd.
std::vector< Watch > watch_
void DispatchOne(const std::chrono::milliseconds &timeout) final
Run one iteration of dispatching select().
Select is an object-oriented wrapper for select().
int select_timeout(double timeout)
Do a select() with timeout (in ms)
std::deque< Callback, mem::GPoolAllocator< Callback > > write_cb
bool active
boolean check whether any callbacks are registered
static constexpr bool self_verify_
Select select_
select() manager object
A Exception is thrown by Connection on all errors instead of returning error codes.
static bool DefaultExceptionCallback()
Default exception handler.
bool SelfPipeCallback()
Self-pipe callback.
static constexpr bool debug
int self_pipe_[2]
self-pipe to wake up select.
char self_pipe_buffer_[32]
buffer to receive one byte signals from self-pipe
std::deque< Callback, mem::GPoolAllocator< Callback > > read_cb
queue of callbacks for fd.
callback vectors per watched file descriptor
#define LOG
Default logging method: output if the local debug variable is true.
Select & ClearRead(int fd)
Clear a file descriptor from the read set.
bool InRead(int fd) const
Check if a file descriptor is in the resulting read set.