proxygen
TestHandler Class Reference
Inheritance diagram for TestHandler:
folly::EventHandler PartialReadHandler PartialWriteHandler

Classes

struct  EventRecord
 

Public Member Functions

 TestHandler (EventBase *eventBase, int fd)
 
void handlerReady (uint16_t events) noexceptoverride
 
- Public Member Functions inherited from folly::EventHandler
 EventHandler (EventBase *eventBase, int fd)
 
 EventHandler (EventBase *eventBase=nullptr, NetworkSocket fd=NetworkSocket())
 
virtual ~EventHandler ()
 
bool registerHandler (uint16_t events)
 
void unregisterHandler ()
 
bool isHandlerRegistered () const
 
void attachEventBase (EventBase *eventBase)
 
void detachEventBase ()
 
void changeHandlerFD (int fd)
 
void changeHandlerFD (NetworkSocket fd)
 
void initHandler (EventBase *eventBase, int fd)
 
void initHandler (EventBase *eventBase, NetworkSocket fd)
 
uint16_t getRegisteredEvents () const
 
bool registerInternalHandler (uint16_t events)
 
bool isPending () const
 

Public Attributes

deque< EventRecordlog
 

Private Attributes

int fd_
 

Additional Inherited Members

- Public Types inherited from folly::EventHandler
enum  EventFlags {
  NONE = 0, READ = EV_READ, WRITE = EV_WRITE, READ_WRITE = (READ | WRITE),
  PERSIST = EV_PERSIST
}
 

Detailed Description

Definition at line 143 of file EventBaseTest.cpp.

Constructor & Destructor Documentation

TestHandler::TestHandler ( EventBase eventBase,
int  fd 
)
inline

Definition at line 145 of file EventBaseTest.cpp.

146  : EventHandler(eventBase, fd), fd_(fd) {}
EventHandler(EventBase *eventBase, int fd)
Definition: EventHandler.h:65

Member Function Documentation

void TestHandler::handlerReady ( uint16_t  events)
inlineoverridevirtualnoexcept

handlerReady() is invoked when the handler is ready.

Parameters
eventsA bitset indicating the events that are ready.

Implements folly::EventHandler.

Reimplemented in PartialWriteHandler, and PartialReadHandler.

Definition at line 148 of file EventBaseTest.cpp.

References readUntilEmpty(), and writeUntilFull().

148  {
149  ssize_t bytesRead = 0;
150  ssize_t bytesWritten = 0;
151  if (events & READ) {
152  // Read all available data, so EventBase will stop calling us
153  // until new data becomes available
154  bytesRead = readUntilEmpty(fd_);
155  }
156  if (events & WRITE) {
157  // Write until the pipe buffer is full, so EventBase will stop calling
158  // us until the other end has read some data
159  bytesWritten = writeUntilFull(fd_);
160  }
161 
162  log.emplace_back(events, bytesRead, bytesWritten);
163  }
size_t writeUntilFull(int fd)
size_t readUntilEmpty(int fd)
deque< EventRecord > log

Member Data Documentation

int TestHandler::fd_
private

Definition at line 181 of file EventBaseTest.cpp.

deque<EventRecord> TestHandler::log

Definition at line 178 of file EventBaseTest.cpp.

Referenced by TEST().


The documentation for this class was generated from the following file: