async-io 1.27.3 → 1.27.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 677b88c0a51a3486d8405a3ab821eb03a655541c8c12a25fca62710c118950bf
4
- data.tar.gz: 1d95b5ff2b3345149fe44f21606c3c43ed31c0c2c433703b389d465c01f4a12f
3
+ metadata.gz: 1e76a27a7d97a50224dc36059306cd3bc34d8fdb644073dcfc7c051e08a1f86c
4
+ data.tar.gz: 581ca97d25191eda6b917de86ef60a0693cb25d45959ed16be7615b573e5e77d
5
5
  SHA512:
6
- metadata.gz: 595931779bcdb4b9b11e68cebc5d617f29fcbbb96a215821a6b5c3ed594b7cfa0e1dcb128ed05cbad8fef5435bfde3f912f4749f21c1ba7b549a20fc2bd02483
7
- data.tar.gz: e0c265f6261ecc351fb9604aa0d7239a4ead84b67c2906cae037ef1baa8c0d32d211938e9d126a000e0c74667f589b5821dbced2aad4765befd7d40fe21329b4
6
+ metadata.gz: 9179c425cd342658b807b3732eec8a7102c638537f785a261de5a60dc983b149a8811f1afa5be854fed3eecc1c52f6311e7126bfc201473fe10de54ee6ae7d59
7
+ data.tar.gz: '06295795fe52e470cda216cda6a7e0f66c27dce7f746573f1eca7d509c71856f5208ce6fd544b4c821cff9f605e391e129b55ab65a3dace590a8ed5c93143506'
@@ -4,6 +4,7 @@ require_relative 'lib/async/io/version'
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "async-io"
6
6
  spec.version = Async::IO::VERSION
7
+ spec.licenses = ["MIT"]
7
8
  spec.authors = ["Samuel Williams"]
8
9
  spec.email = ["samuel.williams@oriontransfer.co.nz"]
9
10
 
@@ -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
@@ -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 8KB.
29
- BLOCK_SIZE = ENV.fetch('ASYNC_IO_BLOCK_SIZE', 1024*8).to_i
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
@@ -22,6 +22,6 @@
22
22
 
23
23
  module Async
24
24
  module IO
25
- VERSION = "1.27.3"
25
+ VERSION = "1.27.4"
26
26
  end
27
27
  end
@@ -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*32)
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
- io.write("Hello World!" * 1024)
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(16*1024)
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.3
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-02-01 00:00:00.000000000 Z
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: []