我正在通过iocp制作一个简单的游戏svr演示
Class Game{
map<string, Table*> all_tables;//tableid-table map
void dispatch(Client *c) //dispatch client command
{
Table *t = all_tables[c->player->roomid];
t->execute(c->packet.cmd, c->packet.data);
}
Class Table{
```//members such as map<uid,Player*> all_players, game_state, table_id``
```//handler such as handler_login(Player*, String &msg),
handler_attack(Player*, String &msg)```
execute(int cmd, Player *p, String &msg);// switch(cmd) case LOGIN:
handler_login(```)
}
main()
{
```//init open a completion port, a worker thread with this port
while(1)
{ worker_socket = accept(``); //block accept
```;
WSARecv(worker_socket, ```, workerIoData->overlapped);
}
}
workerthread(```)
{
```//init
while(true){
ret = GetQueuedCompletionStatus(```);
socket = xxHandlerData->socket
game->dispatch(socket_client_map[socket], data)
}
}
iocp已通过其内部多线程(wsa-api + GetQueuedCompletionStatus)对其aio进行了读取(I / O),此程序是否可以通过打开多工(读取)线程来进行改进?
我听说Nodejs也在多线程中执行I / O,在单线程中执行js代码逻辑,我真的很想知道multi-io线程如何将完成数据传递给单线程。在哪里可以找到关于“多io +单工作线程”的实现的简单明了的文章?(或iocp内部实现的文章?)