async 1.11.0 → 1.12.0

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: f78e59e65f039a595f3090930e0492e824193a02ffd47c77cd640b22ca02706b
4
- data.tar.gz: 2212445905b0c5b3603bec13a64e6e8254d30b9c232f4749b96171b6c13f5279
3
+ metadata.gz: 40cffda648844d0b0a3ec212b9038bb0a211ed98675a9265336af674684ca5a6
4
+ data.tar.gz: b903703231b783e04911f5ea3df63774524fc4248a0c61d3f3a50a74881b4825
5
5
  SHA512:
6
- metadata.gz: 422d14fb58bb6290c2d3761df6fed9cdf647b316c0368b97d6ce0993309f366172bf332dd039dd95c4c384d0c5f77e62a7b4003e18ba8291ac20ecd79c1a14c4
7
- data.tar.gz: 4d748c040e6f630191a3eb64ddf0bb9374c70857e42f1ddcc122c3fd172f7ce2d6104555731237aafdc669691620f3a2c90fae3b2dee05fa7aefc1feea0842bd
6
+ metadata.gz: 5dc2640c9bc451b0a4d43b6a3a54769f564ed139492f18d8350d9e800257d13ac75b2dc321e7b3f9e5d95752e6caab8f7c9b0c593c3cebe590c0eea805b0697a
7
+ data.tar.gz: 3a408f2188b5d2c8ae42267aee14a63aa3e6cff08128a879551506b79de861243d8f5c7200f47a22990a12f99d9a97a61b4194c7770d03c89c9a0191f0cc7f81
@@ -1,16 +1,14 @@
1
1
  language: ruby
2
- sudo: false
3
- dist: trusty
2
+ dist: xenial
4
3
  cache: bundler
4
+
5
5
  addons:
6
6
  apt:
7
7
  packages:
8
8
  - bind9
9
9
 
10
- before_script:
10
+ before_script:
11
11
  - sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6'
12
- - gem update --system
13
- - gem install bundler
14
12
 
15
13
  matrix:
16
14
  include:
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_development_dependency "async-rspec", "~> 1.1"
29
29
 
30
- spec.add_development_dependency "bundler", "~> 1.3"
30
+ spec.add_development_dependency "bundler"
31
31
  spec.add_development_dependency "rspec", "~> 3.6"
32
32
  spec.add_development_dependency "rake"
33
33
  end
@@ -21,7 +21,7 @@
21
21
  require_relative 'condition'
22
22
 
23
23
  module Async
24
- # A synchronization primative, which allows fibers to wait until a notification is received. Does not block the task which signals the notification. Waiting tasks are resumed on next iteration of the reactor.
24
+ # A synchronization primitive, which allows fibers to wait until a notification is received. Does not block the task which signals the notification. Waiting tasks are resumed on next iteration of the reactor.
25
25
  class Notification < Condition
26
26
  # Signal to a given task that it should resume operations.
27
27
  # @return [void]
@@ -45,4 +45,34 @@ module Async
45
45
  @items.shift
46
46
  end
47
47
  end
48
+
49
+ class LimitedQueue < Queue
50
+ def initialize(limit = 1)
51
+ super()
52
+
53
+ @limit = limit
54
+ @full = Async::Condition.new
55
+ end
56
+
57
+ # @return [Boolean] Whether trying to enqueue an item would block.
58
+ def limited?
59
+ @items.size >= @limit
60
+ end
61
+
62
+ def enqueue item
63
+ if limited?
64
+ @full.wait
65
+ end
66
+
67
+ super
68
+ end
69
+
70
+ def dequeue
71
+ item = super
72
+
73
+ @full.signal unless @full.empty?
74
+
75
+ return item
76
+ end
77
+ end
48
78
  end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Async
22
- VERSION = "1.11.0"
22
+ VERSION = "1.12.0"
23
23
  end
@@ -22,9 +22,7 @@ require 'async/queue'
22
22
 
23
23
  require_relative 'condition_examples'
24
24
 
25
- RSpec.describe Async::Queue do
26
- include_context Async::RSpec::Reactor
27
-
25
+ RSpec.shared_context Async::Queue do
28
26
  it 'should process items in order' do
29
27
  reactor.async do |task|
30
28
  10.times do |i|
@@ -38,3 +36,21 @@ RSpec.describe Async::Queue do
38
36
  end
39
37
  end
40
38
  end
39
+
40
+ RSpec.describe Async::Queue do
41
+ include_context Async::RSpec::Reactor
42
+
43
+ it_behaves_like Async::Queue
44
+ end
45
+
46
+ RSpec.describe Async::LimitedQueue do
47
+ include_context Async::RSpec::Reactor
48
+
49
+ it_behaves_like Async::Queue
50
+
51
+ it 'should become limited' do
52
+ expect(subject).to_not be_limited
53
+ subject.enqueue(10)
54
+ expect(subject).to be_limited
55
+ end
56
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-26 00:00:00.000000000 Z
11
+ date: 2018-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nio4r
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '1.3'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '1.3'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -171,8 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0'
173
173
  requirements: []
174
- rubyforge_project:
175
- rubygems_version: 2.7.7
174
+ rubygems_version: 3.0.0.beta3
176
175
  signing_key:
177
176
  specification_version: 4
178
177
  summary: Async is an asynchronous I/O framework based on nio4r.