1
This commit is contained in:
parent
997a1de9b8
commit
48295756bf
@ -23,6 +23,13 @@ enum InnerMesssage_e
|
||||
IM_HandleRedirect
|
||||
};
|
||||
|
||||
enum IoContext_e
|
||||
{
|
||||
IC_Master,
|
||||
IC_Upstream,
|
||||
IC_Max
|
||||
};
|
||||
|
||||
//网络处理对象
|
||||
enum NetHandler_e
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user