1#pragma once 2#include "Common.h" 3#include "Socket.h" 4 5#include <memory> 6 7class InetAddress; 8 9class TcpStream; 10typedef std::unique_ptr<TcpStream> TcpStreamPtr; 11 12class Acceptor : noncopyable 13{ 14 public: 15 explicit Acceptor(const InetAddress& listenAddr); 16 17 ~Acceptor() = default; 18 Acceptor(Acceptor&&) = default; 19 Acceptor& operator=(Acceptor&&) = default; 20 21 // thread safe 22 TcpStreamPtr accept(); 23 Socket acceptSocketOrDie(); 24 25 private: 26 Socket listenSock_; 27}; 28 29 30