- 论坛徽章:
- 1
|
- int BaseTEngine::CallConnList(std::tr1::function<int(Conn *,Conn *,const char *,int,void*)> f,Conn * ActConn,const char *command,int cmdlen,void* n)
- {
- list<Conn *> pconlist;
- pconlist.clear();
- Conn *pNext= NULL, *pcon= NULL;
- ConnList *m_conlist=NULL;
- ConnList* m_UserList = g_pServer->GetUserList();
- for (int i=0; i<g_pServer->GetUserListCount(); i++) {
- m_conlist=&m_UserList[i];
- pthread_rwlock_rdlock(&m_conlist->ConnListLock);
- pcon = m_conlist->GetHead()->GetNext();
- while (pcon != NULL) {
- pNext = pcon->GetNext();
- if(pcon->is_login==1&& pcon->fd_type==1&&pcon->is_down==0)
- pconlist.push_back(pcon);
- pcon = pNext;
- }
- pthread_rwlock_unlock(&m_conlist->ConnListLock);
- }
- Conn *xpconn = NULL;
- list<Conn *>::iterator itor;
- itor=pconlist.begin();
- while(itor!=pconlist.end())
- {
- xpconn=*itor++;
- if(xpconn!=NULL)
- f(xpconn,ActConn,command,cmdlen,n);
- }
- return 0;
- }
- int TServer::send_client(Conn *pcon,Conn *Build_conn,const char *command,int cmdlen,void *p_id)
- {
- int mip=*(int *)p_id;
- if(Build_conn->mip==mip)
- m_TimeThreadInfo->t_Engine->Base_Client_Lock(pcon,command,cmdlen, g_pConf->STRZIP);
- return 0;
- }
- CallConnList(bind(&TServer::send_client, this, tr1::placeholders::_1, tr1::placeholders::_2, tr1::placeholders::_3, tr1::placeholders::_4, tr1::placeholders::_5),pcon,command,DataLen,(void*)&p_id);
复制代码 每次调用都要写这么长- CallConnList(bind(&TServer::send_client, this, tr1::placeholders::_1, tr1::placeholders::_2, tr1::placeholders::_3, tr1::placeholders::_4, tr1::placeholders::_5),pcon,command,DataLen,(void*)&p_id);
复制代码 不方便啊,能不能吧bind移到CallConnList函数里呀 |
|