You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This guide explains how to use `io-event` for non-blocking IO.
4
+
5
+
## Installation
6
+
7
+
Add the gem to your project:
8
+
9
+
~~~bash
10
+
$ bundle add io-event
11
+
~~~
12
+
13
+
## Core Concepts
14
+
15
+
`io-event` has several core concepts:
16
+
17
+
- A {ruby IO::Event::Selector} implementation which provides the primitive operations for implementation an event loop.
18
+
- A {ruby IO::Event::Debug::Selector} which adds extra validations and checks at the expense of performance. You should generally use this during tests.
19
+
20
+
## Basic Event Loop
21
+
22
+
This example shows how to perform a blocking operation
# The reader will be blocked until the IO has data available:
42
+
reader.transfer
43
+
44
+
# Write some data to the pipe and close the writing end:
45
+
writer.transfer
46
+
47
+
selector.select(1)
48
+
49
+
# Results in:
50
+
# {:read=>"Hello World"}
51
+
```
52
+
53
+
## Debugging
54
+
55
+
The {ruby IO::Event::Debug::Selector} class adds extra validations and checks at the expense of performance. It can also log all operations. You can use this by setting the following environment variables:
0 commit comments