-
-
Notifications
You must be signed in to change notification settings - Fork 6
Internal Classes
See documentation
Beam is a fiber-based lightweight executor. Beam scheduled on IO operations and transfer back when IO is ready, so in most cases we can use beams to instead threads to gain better performance.
Watchers::IO is a way to make beams collaborate with 'raw' ruby socket / io objects.
watcher = Watchers::IO.new(socket, :r)
watcher.wait_read
socket.read_nonblock(4096)
watcher.close
watcher.wait_read
will trigger a beam schedule, you must invoke Watchers::IO#wait_read
or Watchers::IO#wait_write
before actually read or write socket, otherwise all beams will blocking until socket is readable/writeable.
LightIO::Library provide Beam compatible libraries, LightIO::Library include same name classes or methods in ruby stdlib, for example use LightIO::Library::Queue
to instead Queue
from stdlib.
You can access LightIO::Library classes from LightIO namespace for convenient, like LightIO::Timeout.timeout
.