MPD
0.20.18
|
Monitor events on a socket. More...
#include <SocketMonitor.hxx>
Public Types | |
typedef std::make_signed< size_t >::type | ssize_t |
Public Member Functions | |
SocketMonitor (EventLoop &_loop) | |
SocketMonitor (int _fd, EventLoop &_loop) | |
~SocketMonitor () | |
EventLoop & | GetEventLoop () |
bool | IsDefined () const |
int | Get () const |
void | Open (int _fd) |
int | Steal () |
"Steal" the socket descriptor. More... | |
void | Abandon () |
Somebody has closed the socket. More... | |
void | Close () |
unsigned | GetScheduledFlags () const |
void | Schedule (unsigned flags) |
void | Cancel () |
void | ScheduleRead () |
void | ScheduleWrite () |
void | CancelRead () |
void | CancelWrite () |
ssize_t | Read (void *data, size_t length) |
ssize_t | Write (const void *data, size_t length) |
void | Dispatch (unsigned flags) |
Static Public Attributes | |
static constexpr unsigned | READ = PollGroup::READ |
static constexpr unsigned | WRITE = PollGroup::WRITE |
static constexpr unsigned | ERROR = PollGroup::ERROR |
static constexpr unsigned | HANGUP = PollGroup::HANGUP |
Protected Member Functions | |
virtual bool | OnSocketReady (unsigned flags)=0 |
Monitor events on a socket.
Call Schedule() to announce events you're interested in, or Cancel() to cancel your subscription. The EventLoop will invoke virtual method OnSocketReady() as soon as any of the subscribed events are ready.
This class does not feel responsible for closing the socket. Call Close() to do it manually.
This class is not thread-safe, all methods must be called from the thread that runs the EventLoop, except where explicitly documented as thread-safe.
Definition at line 54 of file SocketMonitor.hxx.
typedef std::make_signed<size_t>::type SocketMonitor::ssize_t |
Definition at line 69 of file SocketMonitor.hxx.
|
inline |
Definition at line 71 of file SocketMonitor.hxx.
|
inline |
Definition at line 74 of file SocketMonitor.hxx.
SocketMonitor::~SocketMonitor | ( | ) |
void SocketMonitor::Abandon | ( | ) |
Somebody has closed the socket.
Unregister this object.
|
inline |
Definition at line 116 of file SocketMonitor.hxx.
|
inline |
Definition at line 128 of file SocketMonitor.hxx.
|
inline |
Definition at line 132 of file SocketMonitor.hxx.
void SocketMonitor::Close | ( | ) |
void SocketMonitor::Dispatch | ( | unsigned | flags | ) |
|
inline |
Definition at line 87 of file SocketMonitor.hxx.
|
inline |
Definition at line 79 of file SocketMonitor.hxx.
|
inline |
Definition at line 108 of file SocketMonitor.hxx.
|
inline |
Definition at line 83 of file SocketMonitor.hxx.
|
protectedpure virtual |
Implemented in HttpdClient, BufferedSocket, and FullyBufferedSocket.
void SocketMonitor::Open | ( | int | _fd | ) |
ssize_t SocketMonitor::Read | ( | void * | data, |
size_t | length | ||
) |
void SocketMonitor::Schedule | ( | unsigned | flags | ) |
|
inline |
Definition at line 120 of file SocketMonitor.hxx.
|
inline |
Definition at line 124 of file SocketMonitor.hxx.
int SocketMonitor::Steal | ( | ) |
"Steal" the socket descriptor.
This abandons the socket and returns it.
ssize_t SocketMonitor::Write | ( | const void * | data, |
size_t | length | ||
) |
|
static |
Definition at line 66 of file SocketMonitor.hxx.
|
static |
Definition at line 67 of file SocketMonitor.hxx.
|
static |
Definition at line 64 of file SocketMonitor.hxx.
|
static |
Definition at line 65 of file SocketMonitor.hxx.