Skip to content

Commit 629b5dd

Browse files
committed
More README
1 parent 1ce865e commit 629b5dd

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,26 @@ loop do
114114
end
115115
end
116116
```
117+
118+
## Concurrent Execution
119+
120+
Concurrent execution is done by calling `#spin`, which creates a fiber:
121+
122+
```ruby
123+
machine = UringMachine.new
124+
125+
rfd, wfd = machine.pipe
126+
127+
f1 = machine.spin do
128+
machine.write(wfd, 'hello')
129+
machine.write(wfd, 'world')
130+
machine.close(wfd)
131+
end
132+
133+
bgid = machine.setup_buffer_ring(4096, 1024)
134+
f2 = machine.spin do
135+
machine.read_each(rfd, bgid) do |str|
136+
puts str
137+
end
138+
end
139+
```

0 commit comments

Comments
 (0)