Implementing an event timer using boost::asio

后端 未结 3 808
暖寄归人
暖寄归人 2021-01-24 15:42

The sample code looks long, but actually it\'s not so complicated :-)

What I\'m trying to do is, when a user calls EventTimer.Start(), it will execute the callba

3条回答
  •  清歌不尽
    2021-01-24 16:31

    It's not entirely clear to me what you are trying to accomplish, but there's a couple of things that are incorrect in the code you have posted.

    1. io_service::reset() should only be invoked after a previous invocation of io_service::run() was stopped or ran out of work as the documentation describes.
    2. you should not need explicit calls to Sleep(), the call to io_service::run() will block as long as it has work to do.

提交回复
热议问题