This commit is contained in:
azw 2023-05-07 01:07:17 +00:00
parent 997a1de9b8
commit 48295756bf
3 changed files with 25 additions and 0 deletions

View File

@ -23,6 +23,13 @@ enum InnerMesssage_e
IM_HandleRedirect
};
enum IoContext_e
{
IC_Master,
IC_Upstream,
IC_Max
};
//网络处理对象
enum NetHandler_e
{

View File

@ -14,4 +14,15 @@ void IoMgr::UnInit()
}
std::shared_ptr<asio::io_context> IoMgr::GetIoContext(int type)
{
if (type >= 0 && type < io_contexts_.size()) {
auto& s = io_contexts_.at(type);
if (s.empty()) {
return s.at(rand() % s.size());
}
}
return nullptr;
}
#endif

View File

@ -2,6 +2,8 @@
#ifdef USE_ASIO
#include <asio.hpp>
class IoMgr : public a8::Singleton<IoMgr>
{
private:
@ -13,6 +15,11 @@ public:
void Init();
void UnInit();
std::shared_ptr<asio::io_context> GetIoContext(int type);
private:
std::vector<std::vector<std::shared_ptr<asio::io_context>>> io_contexts_;
};
#endif