mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 13:30:06 +00:00
Use boost::asio for asynchronous processing
This commit is contained in:
parent
09064c0be0
commit
bb7793d309
4 changed files with 57 additions and 3 deletions
|
|
@ -1,15 +1,17 @@
|
|||
#include <future>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/post.hpp>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
boost::asio::io_context& io_context();
|
||||
|
||||
template<class F>
|
||||
void async(F&& f)
|
||||
{
|
||||
auto future = std::make_shared<std::future<void>>();
|
||||
*future = std::async(std::launch::async, [future, f]() { f(); });
|
||||
boost::asio::post(io_context(), f);
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue