本文整理汇总了C++中TcpServer::IsRestarting方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpServer::IsRestarting方法的具体用法?C++ TcpServer::IsRestarting怎么用?C++ TcpServer::IsRestarting使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpServer
的用法示例。
在下文中一共展示了TcpServer::IsRestarting方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
/*
int TcpServer::_c2s_client_mio_callback(mio_t m, mio_action_t a, int fd, void *data, void *arg)
*/
int TcpServer::_c2s_client_mio2_callback(mio2_t m, mio2_action_t a, int fd, void *data, void *arg)
{
TcpServer* pthis = NULL;
c2s_t c2s = NULL;
if (arg) {
c2s = (c2s_t)arg;
pthis = (TcpServer*)(((c2s_t)arg)->pvoid);
}
switch(a) {
/*
case action_READ:
*/
case mio2_action_READ:
//do NOT accept new connect while restart
if (pthis->IsRestarting()) {
return 0;
}
return pthis->RevData(fd, m);
/*
case action_WRITE:
*/
case mio2_action_WRITE:
/*
return 0;
*/
return 1;
/*
case action_CLOSE:
*/
case mio2_action_CLOSE:
return 0;
/*
case action_ACCEPT:
*/
case mio2_action_ACCEPT:
//c2s->highfd = GetHighfd(m);
gvLog(LOG_MSG, "(TcpServer::_c2s_client_mio_callback) Accept connect IP=%s(%d)...", data, fd);
//add by using epoll
return 1;
}
return 0;
}
示例2: DataParse
void* TcpServer::DataParse(void* pData)
{
TcpServer* pthis = NULL;
mio2_t m = NULL;
LPMESSAGE_DATA pMsg = NULL;
DataParser* pDataParser = NULL;
if (pData) {
m = ((c2s_t)pData)->mio2;
pthis = (TcpServer*)(((c2s_t)pData)->pvoid);
}
if (!pthis || !m) {
gvLog(LOG_ERR_SYS, "(TcpServer::DataParse) process pool start fail by error param");
return NULL;
}
pDataParser = new DataParser();
if (!pDataParser) goto ErrDataParse;
while (pthis->IsRunning() && !pthis->IsRestarting()) {
pMsg = g_MsgListData->Get_Msg();
if (pMsg) {
gvLog(LOG_MSG, "(TcpServer::DataParse) entering data parser...");
pDataParser->ParserData(pMsg);
gvLog(LOG_MSG, "(TcpServer::DataParse) left data parser...");
g_MsgListSnd->Put_Msg(pMsg);
}
usleep(1);
}
ErrDataParse:
// if (pVerDBMapping) {
// pVerDBMapping->UnInit();
// delete pVerDBMapping;
// }
if (pDataParser) {
delete pDataParser;
}
}