proxygen
folly::ScopedBoundPort Class Reference

#include <ScopedBoundPort.h>

Public Member Functions

 ScopedBoundPort (IPAddress host=IPAddressV6("::1"))
 
 ~ScopedBoundPort ()
 
SocketAddress getAddress () const
 

Private Attributes

std::unique_ptr< ScopedEventBaseThreadebth_
 
std::shared_ptr< AsyncServerSocketsock_
 

Detailed Description

Definition at line 50 of file ScopedBoundPort.h.

Constructor & Destructor Documentation

folly::ScopedBoundPort::ScopedBoundPort ( IPAddress  host = IPAddressV6("::1"))
explicit

Definition at line 25 of file ScopedBoundPort.cpp.

References ebth_, folly::AsyncServerSocket::newSocket(), and sock_.

25  {
26  ebth_ = std::make_unique<ScopedEventBaseThread>();
27  ebth_->getEventBase()->runInEventBaseThreadAndWait([&] {
28  sock_ = AsyncServerSocket::newSocket(ebth_->getEventBase());
29  sock_->bind(SocketAddress(host, 0));
30  });
31 }
std::shared_ptr< AsyncServerSocket > sock_
static std::shared_ptr< AsyncServerSocket > newSocket(EventBase *evb=nullptr)
std::unique_ptr< ScopedEventBaseThread > ebth_
folly::ScopedBoundPort::~ScopedBoundPort ( )

Definition at line 33 of file ScopedBoundPort.cpp.

References ebth_, folly::gen::move, and sock_.

33  {
34  ebth_->getEventBase()->runInEventBaseThread([sock = std::move(sock_)] {});
35 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::shared_ptr< AsyncServerSocket > sock_
std::unique_ptr< ScopedEventBaseThread > ebth_

Member Function Documentation

SocketAddress folly::ScopedBoundPort::getAddress ( ) const

Definition at line 37 of file ScopedBoundPort.cpp.

References sock_.

37  {
38  return sock_->getAddress();
39 }
std::shared_ptr< AsyncServerSocket > sock_

Member Data Documentation

std::unique_ptr<ScopedEventBaseThread> folly::ScopedBoundPort::ebth_
private

Definition at line 57 of file ScopedBoundPort.h.

Referenced by ScopedBoundPort(), and ~ScopedBoundPort().

std::shared_ptr<AsyncServerSocket> folly::ScopedBoundPort::sock_
private

Definition at line 58 of file ScopedBoundPort.h.

Referenced by getAddress(), ScopedBoundPort(), and ~ScopedBoundPort().


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