proxygen
folly::ZeroCopyTest Class Reference

#include <ZeroCopy.h>

Public Member Functions

 ZeroCopyTest (size_t numClients, int numLoops, bool zeroCopy, size_t bufferSize)
 
bool run ()
 

Private Member Functions

void connectAll ()
 

Private Attributes

size_t numClients_
 
size_t counter_
 
int numLoops_
 
bool zeroCopy_
 
size_t bufferSize_
 
EventBase evb_
 
std::vector< std::unique_ptr< ZeroCopyTestAsyncSocket > > clients_
 
folly::AsyncServerSocket::UniquePtr listenSock_
 
ZeroCopyTestServer server_
 

Detailed Description

Definition at line 251 of file ZeroCopy.h.

Constructor & Destructor Documentation

folly::ZeroCopyTest::ZeroCopyTest ( size_t  numClients,
int  numLoops,
bool  zeroCopy,
size_t  bufferSize 
)
explicit

Definition at line 22 of file ZeroCopy.cpp.

References folly::ZeroCopyTestServer::addCallbackToServerSocket(), bufferSize_, clients_, counter_, evb_, i, listenSock_, numClients_, numLoops_, and server_.

27  : numClients_(numClients),
28  counter_(numClients),
29  numLoops_(numLoops),
30  zeroCopy_(zeroCopy),
31  bufferSize_(bufferSize),
33  server_(&evb_, numLoops_, bufferSize_, zeroCopy) {
34  clients_.reserve(numClients_);
35 
36  for (size_t i = 0; i < numClients_; i++) {
37  clients_.emplace_back(std::make_unique<ZeroCopyTestAsyncSocket>(
38  &counter_, &evb_, numLoops_, bufferSize_, zeroCopy));
39  }
40  if (listenSock_) {
42  }
43 }
void addCallbackToServerSocket(folly::AsyncServerSocket &sock)
Definition: ZeroCopy.h:225
ZeroCopyTestServer server_
Definition: ZeroCopy.h:277
std::vector< std::unique_ptr< ZeroCopyTestAsyncSocket > > clients_
Definition: ZeroCopy.h:275
EventBase evb_
Definition: ZeroCopy.h:274
folly::AsyncServerSocket::UniquePtr listenSock_
Definition: ZeroCopy.h:276

Member Function Documentation

void folly::ZeroCopyTest::connectAll ( )
inlineprivate

Definition at line 261 of file ZeroCopy.h.

References addr.

Referenced by run().

261  {
262  SocketAddress addr = listenSock_->getAddress();
263  for (auto& client : clients_) {
264  client->connect(addr);
265  }
266  }
std::vector< std::unique_ptr< ZeroCopyTestAsyncSocket > > clients_
Definition: ZeroCopy.h:275
ThreadPoolListHook * addr
folly::AsyncServerSocket::UniquePtr listenSock_
Definition: ZeroCopy.h:276
bool folly::ZeroCopyTest::run ( )

Definition at line 45 of file ZeroCopy.cpp.

References clients_, connectAll(), evb_, listenSock_, folly::EventBase::loopForever(), folly::EventBase::runInEventBaseThread(), and zeroCopy_.

Referenced by TEST(), zeroCopyOff(), and zeroCopyOn().

45  {
46  evb_.runInEventBaseThread([this]() {
47  if (listenSock_) {
48  listenSock_->bind(0);
49  listenSock_->setZeroCopy(zeroCopy_);
50  listenSock_->listen(10);
51  listenSock_->startAccepting();
52 
53  connectAll();
54  }
55  });
56 
57  evb_.loopForever();
58 
59  for (auto& client : clients_) {
60  if (client->isZeroCopyWriteInProgress()) {
61  return false;
62  }
63  }
64 
65  return true;
66 }
bool runInEventBaseThread(void(*fn)(T *), T *arg)
Definition: EventBase.h:794
std::vector< std::unique_ptr< ZeroCopyTestAsyncSocket > > clients_
Definition: ZeroCopy.h:275
EventBase evb_
Definition: ZeroCopy.h:274
folly::AsyncServerSocket::UniquePtr listenSock_
Definition: ZeroCopy.h:276

Member Data Documentation

size_t folly::ZeroCopyTest::bufferSize_
private

Definition at line 272 of file ZeroCopy.h.

Referenced by ZeroCopyTest().

std::vector<std::unique_ptr<ZeroCopyTestAsyncSocket> > folly::ZeroCopyTest::clients_
private

Definition at line 275 of file ZeroCopy.h.

Referenced by run(), and ZeroCopyTest().

size_t folly::ZeroCopyTest::counter_
private

Definition at line 269 of file ZeroCopy.h.

Referenced by ZeroCopyTest().

EventBase folly::ZeroCopyTest::evb_
private

Definition at line 274 of file ZeroCopy.h.

Referenced by run(), and ZeroCopyTest().

folly::AsyncServerSocket::UniquePtr folly::ZeroCopyTest::listenSock_
private

Definition at line 276 of file ZeroCopy.h.

Referenced by run(), and ZeroCopyTest().

size_t folly::ZeroCopyTest::numClients_
private

Definition at line 268 of file ZeroCopy.h.

Referenced by ZeroCopyTest().

int folly::ZeroCopyTest::numLoops_
private

Definition at line 270 of file ZeroCopy.h.

Referenced by ZeroCopyTest().

ZeroCopyTestServer folly::ZeroCopyTest::server_
private

Definition at line 277 of file ZeroCopy.h.

Referenced by ZeroCopyTest().

bool folly::ZeroCopyTest::zeroCopy_
private

Definition at line 271 of file ZeroCopy.h.

Referenced by run().


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