【发布时间】:2014-04-15 07:39:21
【问题描述】:
例如,我有 2 个线程。我想从主线程(线程 1)停止服务器。
线程 1:主程序
线程 2:TcpServer
来自 libuv 库:
/*
* This function will stop the event loop by forcing uv_run to end
* as soon as possible, but not sooner than the next loop iteration.
* If this function was called before blocking for i/o, the loop won't
* block for i/o on this iteration.
*/
UV_EXTERN void uv_stop(uv_loop_t*);
这意味着,如果我在主线程中调用uv_stop(tcp_server_loop),并且由于 tcpserver 上没有事件,服务器循环将被阻塞,那么服务器将仍然在循环中,直到出现某些事件。 (它可能会检查在循环进入块模式以等待新事件之前是否调用了uv_stop)。
【问题讨论】:
标签: libuv