-
-
Notifications
You must be signed in to change notification settings - Fork 86
Multithreading
Tony Arcieri edited this page Dec 28, 2016
·
2 revisions
nio4r provides internal locking to ensure that it's safe to use from multiple concurrent threads. Only one thread can select on a NIO::Selector
at a given time, and while a thread is selecting other threads are blocked from registering or deregistering IO objects. Once a pending select has completed, requests to register/unregister IO
objects will be processed.
The NIO::Selector#wakeup
method allows one thread to unblock another thread that's in the middle of an NIO::Selector#select
operation. This lets other threads that need to communicate immediately with the selector unblock it so it can process other events that it's not presently selecting on.