boost asynchronous

Method 1: Execute after delay

	  _timer.expires_from_now(boost::posix_time::microseconds(1));
	  _timer.async_wait(boost::bind(&Player::_onTimer, this, boost::asio::placeholders::error));

Method 2: Do not delay execution

	  boost::system::error_code error;
	  _io_service.post(boost::bind(&Player::_onTimer, this, error));

Note: The boost timer is simulated by software, the timer on the virtual machine may cause errors, and the use of async_wait may cause the execution efficiency of the server to decrease! ! !

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_23350817/article/details/111223708