I have a software to listen on ports on three NIC, so I defined TCPServer class which uses boost examples, although I am using C++11 and ASIO.
class TCPServer {
private:
asio::io_service& io_service_;
asio::ip::tcp::acceptor acceptor_;
TCPListener listener_;
public:
TCPServer(asio::io_service& io_service, const tcp::endpoint& listen_endpoint):io_service_(io_service),acceptor_(io_service, listen_endpoint){
start_accept();
}
void quit(){io_service_.stop();}
};
I also defined a manager class to manage as a static kind of variable, so inside each server object, the code can tell all of the servers to quit.
class TCPManager{
private:
static asio::io_service io_service[3];
static TCPServer servers[3];
public:
void static start(){
tcp::endpoint listen_endpoint(tcp::v4(), 502);
TCPServer s0(io_service[0], listen_endpoint);
servers[0]=s0; // how to move here?
}
void quit(){
servers[0].quit();servers[1].quit();servers[2].quit();
}
}
I would like to move the temporary created variable s0 to be a static variable so it can be accessed elsewhere. so I am wondering what should be the content of the move assignment constructor? I do realize that asio::io_service doesn't have a move, so should I just copy it and let it destruct automatically when the temporary variable s0 is out of scope?
Question:
what do I do here?
TCP& operator=TCPServer&& other){
... // I intend to move/copy the io_service_, acceptor_, and listener_ variable to this
return *this;
}
Aucun commentaire:
Enregistrer un commentaire