For example i have 2 threads. I want to stop server from main thread (Thread 1).
Thread 1: main program
Thread 2: TcpServer
From libuv library:
/*
* 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*);
That means, if i would call uv_stop(tcp_server_loop)
in main thread and the server loop will be blocked because of no events on the tcpserver, then the server will be still in the loop till some event appears. (it probably checks if uv_stop
was called before the loop goes to the block mode to wait for new events).