cotag / libuv

Ruby bindings for libuv
Other
60 stars 3 forks source link

How to exec stop callback? #8

Closed Ice-Storm closed 6 years ago

Ice-Storm commented 7 years ago

I'm confused that how to exec stop reactor callback? I see reactor.rb stop_cb function, but it's protected and not have callback params. thx !! And how to restart reactor?

stakach commented 7 years ago

stop_cb is protected as stop is thread safe and stop_cb is not - called internally by Libuv to perform the stopping of the reactor.

The reactor will stop by itself when there is no more IO to process. i.e. once all connections are closed, timers fired etc then the reactor will stop.

Calling stop, stops the reactor when there is still pending IO. This can be desirable - especially when you want to exit and maybe don't care to close everything manually.

Once a reactor is stopped, you can just call run on it again to start it. Any pending IO that existed when you called stop will resume too.

Ice-Storm commented 7 years ago

thank you very much !!

kimburgess commented 6 years ago

Looks like this was all solved. Closing.