Skip to content

Commit 774ba62

Browse files
committed
Bump minor version.
1 parent 73f10dc commit 774ba62

3 files changed

Lines changed: 73 additions & 1 deletion

File tree

context/getting-started.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Getting Started
2+
3+
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
23+
24+
```ruby
25+
require 'fiber'
26+
require 'io/event'
27+
28+
selector = IO::Event::Selector.new(Fiber.current)
29+
input, output = IO.pipe
30+
31+
writer = Fiber.new do
32+
output.write("Hello World")
33+
output.close
34+
end
35+
36+
reader = Fiber.new do
37+
selector.io_wait(Fiber.current, input, IO::READABLE)
38+
pp read: input.read
39+
end
40+
41+
# 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:
56+
57+
```shell
58+
$ IO_EVENT_SELECTOR_DEBUG=y IO_EVENT_SELECTOR_DEBUG_LOG=/dev/stderr bundle exec ./my_script.rb
59+
```
60+
61+
The format of the log is subject to change, but it may be useful for debugging.

context/index.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Automatically generated context index for Utopia::Project guides.
2+
# Do not edit then files in this directory directly, instead edit the guides and then run `bake utopia:project:agent:context:update`.
3+
---
4+
description: An event loop.
5+
metadata:
6+
documentation_uri: https://socketry.github.io/io-event/
7+
source_code_uri: https://github.com/socketry/io-event.git
8+
files:
9+
- path: getting-started.md
10+
title: Getting Started
11+
description: This guide explains how to use `io-event` for non-blocking IO.

lib/io/event/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
class IO
88
# @namespace
99
module Event
10-
VERSION = "1.12.1"
10+
VERSION = "1.13.0"
1111
end
1212
end

0 commit comments

Comments
 (0)