fastdo  0.6.16
eiennet::IoService类 参考

IO服务 更多...

#include <eiennet_async.hpp>

Public 类型

using IoMapMap = std::map< winux::SharedPointer< AsyncSocket >, std::map< IoType, winux::SharedPointer< IoCtx > > >
 
using IoMap = IoMapMap::mapped_type
 
using RunBeforeJoinHandlerFunction = std::function< void() >
 
using RunAfterWaitHandlerFunction = std::function< void(int rc) >
 

Public 成员函数

 IoService (int threadCount=4, double serverWait=0.002)
 构造函数 更多...
 
virtual ~IoService ()
 析构函数 更多...
 
bool init (int threadCount=4, double serverWait=0.002)
 初始化 更多...
 
void stop (bool b=true)
 停止监听服务 更多...
 
void postAccept (winux::SharedPointer< AsyncSocket > sock, IoAcceptCtx::OkFunction cbOk, winux::uint64 timeoutMs=-1, IoAcceptCtx::TimeoutFunction cbTimeout=nullptr)
 
void postConnect (winux::SharedPointer< AsyncSocket > sock, EndPoint const &ep, IoConnectCtx::OkFunction cbOk, winux::uint64 timeoutMs=-1, IoConnectCtx::TimeoutFunction cbTimeout=nullptr)
 
void postRecv (winux::SharedPointer< AsyncSocket > sock, size_t targetSize, IoRecvCtx::OkFunction cbOk, winux::uint64 timeoutMs=-1, IoRecvCtx::TimeoutFunction cbTimeout=nullptr)
 
void postSend (winux::SharedPointer< AsyncSocket > sock, void const *data, size_t size, IoSendCtx::OkFunction cbOk, winux::uint64 timeoutMs=-1, IoSendCtx::TimeoutFunction cbTimeout=nullptr)
 
void postRecvFrom (winux::SharedPointer< AsyncSocket > sock, size_t targetSize, IoRecvFromCtx::OkFunction cbOk, winux::uint64 timeoutMs=-1, IoRecvFromCtx::TimeoutFunction cbTimeout=nullptr)
 
void postSendTo (winux::SharedPointer< AsyncSocket > sock, EndPoint const &ep, void const *data, size_t size, IoSendToCtx::OkFunction cbOk, winux::uint64 timeoutMs=-1, IoSendToCtx::TimeoutFunction cbTimeout=nullptr)
 
int run ()
 运行 更多...
 
void getSockIoCount (size_t *sockCount, size_t *ioCount) const
 获取监听的socks数,IO数 更多...
 
void removeSock (winux::SharedPointer< AsyncSocket > sock)
 移除指定sock的所有IO监听 更多...
 
winux::ThreadPoolgetPool ()
 
IoMapMapgetIoMaps ()
 
winux::MutexgetMutex ()
 
void onRunBeforeJoinHandler (RunBeforeJoinHandlerFunction handler)
 
void onRunAfterWaitHandler (RunAfterWaitHandlerFunction handler)
 

Protected 成员函数

void _post (winux::SharedPointer< AsyncSocket > sock, IoType type, winux::SharedPointer< IoCtx > ctx)
 投递IO请求 更多...
 
virtual void onRunBeforeJoin ()
 
virtual void onRunAfterWait (int rc)
 

Protected 属性

RunBeforeJoinHandlerFunction _RunBeforeJoinHandler
 
RunAfterWaitHandlerFunction _RunAfterWaitHandler
 

友元

class AsyncSocket
 

详细描述

IO服务

在文件 eiennet_async.hpp130 行定义.

成员类型定义说明

using eiennet::IoService::IoMap = IoMapMap::mapped_type

在文件 eiennet_async.hpp134 行定义.

using eiennet::IoService::RunBeforeJoinHandlerFunction = std::function< void () >

在文件 eiennet_async.hpp177 行定义.

using eiennet::IoService::RunAfterWaitHandlerFunction = std::function< void ( int rc ) >

在文件 eiennet_async.hpp179 行定义.

构造及析构函数说明

eiennet::IoService::IoService ( int  threadCount = 4,
double  serverWait = 0.002 
)

构造函数

参数
threadCountint 线程数
serverWaitdouble 服务器等待时间(ms)
virtual eiennet::IoService::~IoService ( )
virtual

析构函数

成员函数说明

bool eiennet::IoService::init ( int  threadCount = 4,
double  serverWait = 0.002 
)

初始化

void eiennet::IoService::stop ( bool  b = true)

停止监听服务

void eiennet::IoService::postAccept ( winux::SharedPointer< AsyncSocket sock,
IoAcceptCtx::OkFunction  cbOk,
winux::uint64  timeoutMs = -1,
IoAcceptCtx::TimeoutFunction  cbTimeout = nullptr 
)
void eiennet::IoService::postConnect ( winux::SharedPointer< AsyncSocket sock,
EndPoint const &  ep,
IoConnectCtx::OkFunction  cbOk,
winux::uint64  timeoutMs = -1,
IoConnectCtx::TimeoutFunction  cbTimeout = nullptr 
)
void eiennet::IoService::postRecv ( winux::SharedPointer< AsyncSocket sock,
size_t  targetSize,
IoRecvCtx::OkFunction  cbOk,
winux::uint64  timeoutMs = -1,
IoRecvCtx::TimeoutFunction  cbTimeout = nullptr 
)
void eiennet::IoService::postSend ( winux::SharedPointer< AsyncSocket sock,
void const *  data,
size_t  size,
IoSendCtx::OkFunction  cbOk,
winux::uint64  timeoutMs = -1,
IoSendCtx::TimeoutFunction  cbTimeout = nullptr 
)
void eiennet::IoService::postRecvFrom ( winux::SharedPointer< AsyncSocket sock,
size_t  targetSize,
IoRecvFromCtx::OkFunction  cbOk,
winux::uint64  timeoutMs = -1,
IoRecvFromCtx::TimeoutFunction  cbTimeout = nullptr 
)
void eiennet::IoService::postSendTo ( winux::SharedPointer< AsyncSocket sock,
EndPoint const &  ep,
void const *  data,
size_t  size,
IoSendToCtx::OkFunction  cbOk,
winux::uint64  timeoutMs = -1,
IoSendToCtx::TimeoutFunction  cbTimeout = nullptr 
)
int eiennet::IoService::run ( )

运行

void eiennet::IoService::getSockIoCount ( size_t *  sockCount,
size_t *  ioCount 
) const

获取监听的socks数,IO数

void eiennet::IoService::removeSock ( winux::SharedPointer< AsyncSocket sock)

移除指定sock的所有IO监听

winux::ThreadPool& eiennet::IoService::getPool ( )
inline

在文件 eiennet_async.hpp167 行定义.

IoMapMap& eiennet::IoService::getIoMaps ( )
inline

在文件 eiennet_async.hpp168 行定义.

winux::Mutex& eiennet::IoService::getMutex ( )
inline

在文件 eiennet_async.hpp169 行定义.

void eiennet::IoService::_post ( winux::SharedPointer< AsyncSocket sock,
IoType  type,
winux::SharedPointer< IoCtx ctx 
)
protected

投递IO请求

void eiennet::IoService::onRunBeforeJoinHandler ( RunBeforeJoinHandlerFunction  handler)
inline

在文件 eiennet_async.hpp177 行定义.

virtual void eiennet::IoService::onRunBeforeJoin ( )
inlineprotectedvirtual

在文件 eiennet_async.hpp177 行定义.

void eiennet::IoService::onRunAfterWaitHandler ( RunAfterWaitHandlerFunction  handler)
inline

在文件 eiennet_async.hpp179 行定义.

virtual void eiennet::IoService::onRunAfterWait ( int  rc)
inlineprotectedvirtual

在文件 eiennet_async.hpp179 行定义.

友元及相关函数文档

friend class AsyncSocket
friend

在文件 eiennet_async.hpp190 行定义.

类成员变量说明

RunBeforeJoinHandlerFunction eiennet::IoService::_RunBeforeJoinHandler
protected

在文件 eiennet_async.hpp177 行定义.

RunAfterWaitHandlerFunction eiennet::IoService::_RunAfterWaitHandler
protected

在文件 eiennet_async.hpp179 行定义.


该类的文档由以下文件生成: