提交 65088fb5 编写于 作者: Y youngwolf

Support customizing the distribution of multipal io_contexts.

上级 d5e4b35e
Subproject commit d038fb3c2fb56fb91ff1d17b0715cff7887aa09e
Subproject commit 08a7029cb10c911b6fb66fb015217a431206e52c
......@@ -40,7 +40,7 @@ template <typename Socket> std::thread create_sync_recv_thread(Socket& socket)
});
}
//because st_asio_wrapper is header only, it cannot provide the implementation of below global function, but kcp needs it,
//because ascs is header only, it cannot provide the implementation of below global function, but kcp needs it,
//you're supposed to provide it and call reliable_socket_base::output directly in it, like:
int output(const char* buf, int len, ikcpcb * kcp, void* user) {return ((single_reliable_socket_service*) user)->output(buf, len);}
......
......@@ -164,15 +164,15 @@ public:
throw "no available io_context!";
}
void return_io_context(const asio::execution_context& io_context)
void return_io_context(const asio::execution_context& io_context, unsigned refs = 1)
{
if (!single_io_context)
ascs::do_something_to_one(context_can, context_can_mutex, [&](context& item) {return &io_context != &item.io_context ? false : (--item.refs, true);});
ascs::do_something_to_one(context_can, context_can_mutex, [&](context& item) {return &io_context != &item.io_context ? false : (item.refs -= refs, true);});
}
void assign_io_context(const asio::execution_context& io_context)
void assign_io_context(const asio::execution_context& io_context, unsigned refs = 1)
{
if (!single_io_context)
ascs::do_something_to_one(context_can, context_can_mutex, [&](context& item) {return &io_context != &item.io_context ? false : (++item.refs, true);});
ascs::do_something_to_one(context_can, context_can_mutex, [&](context& item) {return &io_context != &item.io_context ? false : (item.refs += refs, true);});
}
object_type find(int id)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册