proxygen
TestAsyncTransport::ReadEvent Class Reference

Public Member Functions

 ReadEvent (const void *buf, size_t buflen, std::chrono::milliseconds delay)
 
 ReadEvent (const folly::AsyncSocketException &ex, std::chrono::milliseconds delay)
 
 ~ReadEvent ()
 
std::chrono::milliseconds getDelay () const
 
bool isFinalEvent () const
 
const char * getBuffer () const
 
size_t getLength () const
 
void consumeData (size_t length)
 
bool isError () const
 
const folly::AsyncSocketExceptiongetException () const
 

Private Attributes

char * buffer_
 
char * readStart_
 
char * dataEnd_
 
bool isError_
 
folly::AsyncSocketException exception_
 
std::chrono::milliseconds delay_
 

Detailed Description

Definition at line 31 of file TestAsyncTransport.cpp.

Constructor & Destructor Documentation

TestAsyncTransport::ReadEvent::ReadEvent ( const void *  buf,
size_t  buflen,
std::chrono::milliseconds  delay 
)
inline

Definition at line 33 of file TestAsyncTransport.cpp.

References buffer_, dataEnd_, and readStart_.

34  : buffer_(nullptr),
35  readStart_(nullptr),
36  dataEnd_(nullptr),
37  isError_(false),
39  delay_(delay) {
40  if (buflen == 0) {
41  // This means EOF
42  return;
43  }
44  CHECK_NOTNULL(buf);
45 
46  buffer_ = static_cast<char*>(malloc(buflen));
47  if (buffer_ == nullptr) {
48  throw std::bad_alloc();
49  }
50  memcpy(buffer_, buf, buflen);
52  dataEnd_ = buffer_ + buflen;
53  }
std::chrono::milliseconds delay_
folly::AsyncSocketException exception_
TestAsyncTransport::ReadEvent::ReadEvent ( const folly::AsyncSocketException ex,
std::chrono::milliseconds  delay 
)
inline

Definition at line 55 of file TestAsyncTransport.cpp.

56  : buffer_(nullptr),
57  readStart_(nullptr),
58  dataEnd_(nullptr),
59  isError_(true),
60  exception_(ex),
61  delay_(delay) {}
std::chrono::milliseconds delay_
folly::AsyncSocketException exception_
TestAsyncTransport::ReadEvent::~ReadEvent ( )
inline

Definition at line 63 of file TestAsyncTransport.cpp.

References buffer_, and bm::free().

63  {
64  free(buffer_);
65  }
void free()

Member Function Documentation

void TestAsyncTransport::ReadEvent::consumeData ( size_t  length)
inline

Definition at line 83 of file TestAsyncTransport.cpp.

References dataEnd_, and readStart_.

83  {
84  CHECK_LE(readStart_ + length, dataEnd_);
85  readStart_ += length;
86  }
const char* TestAsyncTransport::ReadEvent::getBuffer ( ) const
inline

Definition at line 75 of file TestAsyncTransport.cpp.

References readStart_.

75  {
76  return readStart_;
77  }
std::chrono::milliseconds TestAsyncTransport::ReadEvent::getDelay ( ) const
inline

Definition at line 67 of file TestAsyncTransport.cpp.

References delay_.

67  {
68  return delay_;
69  }
std::chrono::milliseconds delay_
const folly::AsyncSocketException& TestAsyncTransport::ReadEvent::getException ( ) const
inline

Definition at line 92 of file TestAsyncTransport.cpp.

References exception_.

92  {
93  return exception_;
94  }
folly::AsyncSocketException exception_
size_t TestAsyncTransport::ReadEvent::getLength ( ) const
inline

Definition at line 79 of file TestAsyncTransport.cpp.

References dataEnd_, and readStart_.

bool TestAsyncTransport::ReadEvent::isError ( ) const
inline

Definition at line 88 of file TestAsyncTransport.cpp.

References isError_.

88  {
89  return isError_;
90  }
bool TestAsyncTransport::ReadEvent::isFinalEvent ( ) const
inline

Definition at line 71 of file TestAsyncTransport.cpp.

References buffer_.

71  {
72  return buffer_ == nullptr;
73  }

Member Data Documentation

char* TestAsyncTransport::ReadEvent::buffer_
private

Definition at line 97 of file TestAsyncTransport.cpp.

Referenced by isFinalEvent(), ReadEvent(), and ~ReadEvent().

char* TestAsyncTransport::ReadEvent::dataEnd_
private

Definition at line 99 of file TestAsyncTransport.cpp.

Referenced by consumeData(), getLength(), and ReadEvent().

std::chrono::milliseconds TestAsyncTransport::ReadEvent::delay_
private

Definition at line 104 of file TestAsyncTransport.cpp.

Referenced by getDelay().

folly::AsyncSocketException TestAsyncTransport::ReadEvent::exception_
private

Definition at line 102 of file TestAsyncTransport.cpp.

Referenced by getException().

bool TestAsyncTransport::ReadEvent::isError_
private

Definition at line 101 of file TestAsyncTransport.cpp.

Referenced by isError().

char* TestAsyncTransport::ReadEvent::readStart_
private

Definition at line 98 of file TestAsyncTransport.cpp.

Referenced by consumeData(), getBuffer(), getLength(), and ReadEvent().


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