LogCabin
|
A File is called by the Event::Loop when a file becomes readable or writable. More...
#include <File.h>
Classes | |
class | Monitor |
Registers a File handler to be monitored by the Event::Loop. More... | |
Public Types | |
enum | Ownership { CLOSE_ON_DESTROY, CALLER_CLOSES_FD } |
Specifies who is in charge of closing the file descriptor. More... | |
Public Member Functions | |
File (int fd, Ownership ownership=CLOSE_ON_DESTROY) | |
Construct a file event handler. | |
virtual | ~File () |
Destructor. | |
virtual void | handleFileEvent (uint32_t events)=0 |
This method is overridden by a subclass and invoked when a file event occurs. | |
File (const File &) | |
File & | operator= (const File &) |
Public Attributes | |
const int | fd |
The file descriptor to monitor. | |
const Ownership | ownership |
See Ownership. |
A File is called by the Event::Loop when a file becomes readable or writable.
The client should inherit from this and implement the handleFileEvent() method for when the file becomes readable or writable.
File objects can be created from any thread, but they will always fire on the thread running the Event::Loop.
LogCabin::Event::File::File | ( | int | fd, |
Ownership | ownership = CLOSE_ON_DESTROY |
||
) | [explicit] |
Construct a file event handler.
After this is constructed, you'll want to create an Event::File::Monitor for it.
fd | A file descriptor of a valid open file to monitor. Unless release() is called first, this File object will close the file descriptor when it is destroyed. |
ownership | Specifies who is in charge of closing fd. Default: this class will close fd in the destructor. |
LogCabin::Event::File::~File | ( | ) | [virtual] |
LogCabin::Event::File::File | ( | const File & | ) |
virtual void LogCabin::Event::File::handleFileEvent | ( | uint32_t | events | ) | [pure virtual] |
This method is overridden by a subclass and invoked when a file event occurs.
This method will be invoked by the main event loop on whatever thread is running the Event::Loop.
If the event still exists when this method returns (e.g., the file is readable but the method did not read the data), then the method will be invoked again (unless flags such as EPOLLONESHOT or EPOLLET are used).
events | Indicates whether the file is readable or writable or both (OR'ed combination of EPOLL_EVENTS values). |
Implemented in LogCabin::RPC::OpaqueServer::BoundListener, LogCabin::RPC::MessageSocket::ReceiveSocket, LogCabin::RPC::MessageSocket::SendSocket, LogCabin::Event::Signal, LogCabin::Event::Timer, and LogCabin::RPC::anonymous_namespace{ClientSession.cc}::FileNotifier.
const int LogCabin::Event::File::fd |