Skip to content

Shutting down the server from another thread #1139

Answered by ghost
tommitytom asked this question in Q&A
Discussion options

You must be logged in to vote

You cannot shut down the server from another thread but you can Loop::defer the shutting down from any thread:

// From the thread where the loop runs we get and store the loop ptr
Loop *loopToShutdown = Loop::get();

// Loop * is directly castable to us_loop_t *

// From any thread
loopToShutdown->defer([]() {
  us_listen_socket_close(...)
});

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #1139 on December 11, 2020 06:42.