proxygen
ServerThread Class Reference

Public Member Functions

 ServerThread (HTTPServer *server)
 
 ~ServerThread ()
 
bool start ()
 

Private Attributes

boost::barrier barrier_ {2}
 
std::thread t_
 
HTTPServerserver_ {nullptr}
 

Detailed Description

Definition at line 45 of file HTTPServerTest.cpp.

Constructor & Destructor Documentation

ServerThread::ServerThread ( HTTPServer server)
inlineexplicit

Definition at line 53 of file HTTPServerTest.cpp.

53 : server_(server) {}
HTTPServer * server_
ServerThread::~ServerThread ( )
inline

Definition at line 54 of file HTTPServerTest.cpp.

54  {
55  if (server_) {
56  server_->stop();
57  }
58  t_.join();
59  }
std::thread t_
HTTPServer * server_

Member Function Documentation

bool ServerThread::start ( )
inline

Definition at line 61 of file HTTPServerTest.cpp.

61  {
62  bool throws = false;
63  t_ = std::thread([&]() {
64  server_->start([&]() { barrier_.wait(); },
65  [&](std::exception_ptr /*ex*/) {
66  throws = true;
67  server_ = nullptr;
68  barrier_.wait();
69  });
70  });
71  barrier_.wait();
72  return !throws;
73  }
std::thread t_
void start(std::function< void()> onSuccess=nullptr, std::function< void(std::exception_ptr)> onError=nullptr)
Definition: HTTPServer.cpp:119
boost::barrier barrier_
HTTPServer * server_

Member Data Documentation

boost::barrier ServerThread::barrier_ {2}
private

Definition at line 47 of file HTTPServerTest.cpp.

HTTPServer* ServerThread::server_ {nullptr}
private

Definition at line 49 of file HTTPServerTest.cpp.

std::thread ServerThread::t_
private

Definition at line 48 of file HTTPServerTest.cpp.


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