async-io 1.27.3 → 1.27.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/async-io.gemspec +1 -0
- data/examples/defer/worker.rb +29 -0
- data/lib/async/io/generic.rb +2 -2
- data/lib/async/io/version.rb +1 -1
- data/spec/async/io/stream_spec.rb +5 -3
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e76a27a7d97a50224dc36059306cd3bc34d8fdb644073dcfc7c051e08a1f86c
|
4
|
+
data.tar.gz: 581ca97d25191eda6b917de86ef60a0693cb25d45959ed16be7615b573e5e77d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9179c425cd342658b807b3732eec8a7102c638537f785a261de5a60dc983b149a8811f1afa5be854fed3eecc1c52f6311e7126bfc201473fe10de54ee6ae7d59
|
7
|
+
data.tar.gz: '06295795fe52e470cda216cda6a7e0f66c27dce7f746573f1eca7d509c71856f5208ce6fd544b4c821cff9f605e391e129b55ab65a3dace590a8ed5c93143506'
|
data/async-io.gemspec
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'async'
|
4
|
+
require 'async/io/notification'
|
5
|
+
|
6
|
+
def defer(*args, &block)
|
7
|
+
Async do
|
8
|
+
notification = Async::IO::Notification.new
|
9
|
+
|
10
|
+
thread = Thread.new(*args) do
|
11
|
+
yield
|
12
|
+
ensure
|
13
|
+
notification.signal
|
14
|
+
end
|
15
|
+
|
16
|
+
notification.wait
|
17
|
+
thread.join
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Async do
|
22
|
+
10.times do
|
23
|
+
defer do
|
24
|
+
puts "I'm going to sleep"
|
25
|
+
sleep 1
|
26
|
+
puts "I'm going to wake up"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/async/io/generic.rb
CHANGED
@@ -25,8 +25,8 @@ require 'forwardable'
|
|
25
25
|
|
26
26
|
module Async
|
27
27
|
module IO
|
28
|
-
# The default block size for IO buffers. Defaults to
|
29
|
-
BLOCK_SIZE = ENV.fetch('ASYNC_IO_BLOCK_SIZE', 1024*
|
28
|
+
# The default block size for IO buffers. Defaults to 64KB (typical pipe buffer size).
|
29
|
+
BLOCK_SIZE = ENV.fetch('ASYNC_IO_BLOCK_SIZE', 1024*64).to_i
|
30
30
|
|
31
31
|
# The maximum read size when appending to IO buffers. Defaults to 8MB.
|
32
32
|
MAXIMUM_READ_SIZE = ENV.fetch('ASYNC_IO_MAXIMUM_READ_SIZE', BLOCK_SIZE * 128 * 8).to_i
|
data/lib/async/io/version.rb
CHANGED
@@ -30,7 +30,7 @@ RSpec.describe Async::IO::Stream do
|
|
30
30
|
# This constant is part of the public interface, but was renamed to `Async::IO::BLOCK_SIZE`.
|
31
31
|
describe "::BLOCK_SIZE" do
|
32
32
|
it "should exist and be reasonable" do
|
33
|
-
expect(Async::IO::Stream::BLOCK_SIZE).to be_between(1024, 1024*
|
33
|
+
expect(Async::IO::Stream::BLOCK_SIZE).to be_between(1024, 1024*128)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -241,7 +241,9 @@ RSpec.describe Async::IO::Stream do
|
|
241
241
|
|
242
242
|
describe '#read_partial' do
|
243
243
|
before(:each) do
|
244
|
-
|
244
|
+
string = "Hello World!"
|
245
|
+
|
246
|
+
io.write(string * (1 + (Async::IO::BLOCK_SIZE / string.bytesize)))
|
245
247
|
io.seek(0)
|
246
248
|
end
|
247
249
|
|
@@ -260,7 +262,7 @@ RSpec.describe Async::IO::Stream do
|
|
260
262
|
|
261
263
|
it "allocates exact number of bytes being read" do
|
262
264
|
expect do
|
263
|
-
subject.read_partial(
|
265
|
+
subject.read_partial(subject.block_size * 2)
|
264
266
|
end.to limit_allocations.of(String, count: 1, size: 0)
|
265
267
|
end
|
266
268
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.27.
|
4
|
+
version: 1.27.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- examples/allocations/read_chunks.rb
|
130
130
|
- examples/chat/client.rb
|
131
131
|
- examples/chat/server.rb
|
132
|
+
- examples/defer/worker.rb
|
132
133
|
- examples/echo/client.rb
|
133
134
|
- examples/echo/server.rb
|
134
135
|
- examples/issues/broken_ssl.rb
|
@@ -193,7 +194,8 @@ files:
|
|
193
194
|
- spec/async/io/wrap/tcp_spec.rb
|
194
195
|
- spec/spec_helper.rb
|
195
196
|
homepage: https://github.com/socketry/async-io
|
196
|
-
licenses:
|
197
|
+
licenses:
|
198
|
+
- MIT
|
197
199
|
metadata: {}
|
198
200
|
post_install_message:
|
199
201
|
rdoc_options: []
|