async 0.11.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1747c272a59477827b3ca9e4a3b1a27bbe995b92
4
- data.tar.gz: 418f2d203b464d91e75b2f0a55a3288927af4418
3
+ metadata.gz: 258d52bc85cb637bab0e3654089c848850ec8cd2
4
+ data.tar.gz: 8981a28373b74a1e0eb70049a722ca54e47a7c0b
5
5
  SHA512:
6
- metadata.gz: 3a065e73686d2175ec2b6d605fc81b3ab085ae4b3f4e944d10cef60e15abaa202518a37136b88fa3bb142c5ef0947872b4fdcbe181012211c60ebb3de67811cd
7
- data.tar.gz: ff5236af82d181c055930c64116f7dca549748c148de866a6148305b52ad1bb8a5b70a0038f2fa0d49f23bfe108dd9d096c1cfd862e2151ed45e4d25bb80a758
6
+ metadata.gz: ed62d3ec9840675cf7ab5c7f9f248ecbd55eebf0161631681a5ced37696bb48f97c3a4ba0bde7eb75adf0058da594345398f7774bdbbf22f540799132bb5b2e2
7
+ data.tar.gz: 9b60cf5994d40adc383fd346681cdc6f2e1bf7d40a0ad43bc9370755fd851492fec18e61cafa1abf6fe71392d767a1608a787e5aade7d171bb173839d27d723b
data/.travis.yml CHANGED
@@ -3,6 +3,8 @@ sudo: false
3
3
  dist: trusty
4
4
  cache: bundler
5
5
  rvm:
6
+ - 2.0
7
+ - 2.1
6
8
  - 2.2.6
7
9
  - 2.3.3
8
10
  - 2.4.0
data/README.md CHANGED
@@ -48,41 +48,41 @@ require 'async'
48
48
  require 'async/tcp_socket'
49
49
 
50
50
  def echo_server
51
- Async::Reactor.run do |task|
52
- # This is a synchronous block within the current task:
53
- task.with(TCPServer.new('localhost', 9000)) do |server|
54
-
55
- # This is an asynchronous block within the current reactor:
56
- task.reactor.with(server.accept) do |client|
57
- data = client.read(512)
58
-
59
- task.sleep(rand)
60
-
61
- client.write(data)
62
- end while true
63
- end
64
- end
51
+ Async::Reactor.run do |task|
52
+ # This is a synchronous block within the current task:
53
+ task.with(TCPServer.new('localhost', 9000)) do |server|
54
+
55
+ # This is an asynchronous block within the current reactor:
56
+ task.reactor.with(server.accept) do |client|
57
+ data = client.read(512)
58
+
59
+ task.sleep(rand)
60
+
61
+ client.write(data)
62
+ end while true
63
+ end
64
+ end
65
65
  end
66
66
 
67
67
  def echo_client(data)
68
- Async::Reactor.run do |task|
69
- Async::TCPServer.connect('localhost', 9000) do |socket|
70
- socket.write(data)
71
- puts "echo_client: #{socket.read(512)}"
72
- end
73
- end
68
+ Async::Reactor.run do |task|
69
+ Async::TCPServer.connect('localhost', 9000) do |socket|
70
+ socket.write(data)
71
+ puts "echo_client: #{socket.read(512)}"
72
+ end
73
+ end
74
74
  end
75
75
 
76
76
  Async::Reactor.run do
77
- # Start the echo server:
78
- server = echo_server
79
-
80
- 5.times.collect do |i|
81
- echo_client("Hello World #{i}")
82
- end.each(&:wait) # Wait until all clients are finished.
83
-
84
- # Terminate the server and all tasks created within it's async scope:
85
- server.stop
77
+ # Start the echo server:
78
+ server = echo_server
79
+
80
+ 5.times.collect do |i|
81
+ echo_client("Hello World #{i}")
82
+ end.each(&:wait) # Wait until all clients are finished.
83
+
84
+ # Terminate the server and all tasks created within it's async scope:
85
+ server.stop
86
86
  end
87
87
  ```
88
88
 
@@ -122,7 +122,7 @@ dropped.
122
122
  ## See Also
123
123
 
124
124
  - [async-dns](https://github.com/socketry/async-dns) — Asynchronous DNS resolver and server.
125
- - [rubydns](https://github.com/socketry/rubydns) — A easy to use Ruby DNS server.
125
+ - [rubydns](https://github.com/ioquatix/rubydns) — A easy to use Ruby DNS server.
126
126
 
127
127
  ## License
128
128
 
data/async.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.require_paths = ["lib"]
22
22
  spec.has_rdoc = "yard"
23
23
 
24
- spec.required_ruby_version = ">= 2.2.6"
24
+ spec.required_ruby_version = ">= 2.0.0"
25
25
 
26
26
  spec.add_runtime_dependency "nio4r"
27
27
  spec.add_runtime_dependency "timers", "~> 4.1"
data/lib/async/reactor.rb CHANGED
@@ -116,20 +116,20 @@ module Async
116
116
  # - +ve: timers waiting to fire
117
117
  interval = 0 if interval && interval < 0
118
118
 
119
- Async.logger.debug "[#{self} Pre] Updating #{@children.count} children..."
120
- Async.logger.debug @children.collect{|child| [child.to_s, child.alive?]}.inspect
119
+ Async.logger.debug{"[#{self} Pre] Updating #{@children.count} children..."}
120
+ Async.logger.debug{@children.collect{|child| [child.to_s, child.alive?]}.inspect}
121
121
  # As timeouts may have been updated, and caused fibers to complete, we should check this.
122
122
 
123
123
  # If there is nothing to do, then finish:
124
- Async.logger.debug "[#{self}] @children.empty? = #{@children.empty?} && interval #{interval.inspect}"
124
+ Async.logger.debug{"[#{self}] @children.empty? = #{@children.empty?} && interval #{interval.inspect}"}
125
125
  return if @children.empty? && interval.nil?
126
126
 
127
- Async.logger.debug "Selecting with #{@children.count} fibers interval = #{interval}..."
127
+ Async.logger.debug{"Selecting with #{@children.count} fibers interval = #{interval}..."}
128
128
  if monitors = @selector.select(interval)
129
129
  monitors.each do |monitor|
130
- if task = monitor.value
130
+ if fiber = monitor.value
131
131
  # Async.logger.debug "Resuming task #{task} due to IO..."
132
- task.resume
132
+ fiber.resume
133
133
  end
134
134
  end
135
135
  end
@@ -137,8 +137,8 @@ module Async
137
137
 
138
138
  return self
139
139
  ensure
140
- Async.logger.debug "[#{self} Ensure] Exiting run-loop (stopped: #{@stopped} exception: #{$!})..."
141
- Async.logger.debug @children.collect{|child| [child.to_s, child.alive?]}.inspect
140
+ Async.logger.debug{"[#{self} Ensure] Exiting run-loop (stopped: #{@stopped} exception: #{$!})..."}
141
+ Async.logger.debug{@children.collect{|child| [child.to_s, child.alive?]}.inspect}
142
142
  @stopped = true
143
143
  end
144
144
 
data/lib/async/version.rb CHANGED
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Async
22
- VERSION = "0.11.0"
22
+ VERSION = "0.11.1"
23
23
  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: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-09 00:00:00.000000000 Z
11
+ date: 2017-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nio4r
@@ -147,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - ">="
149
149
  - !ruby/object:Gem::Version
150
- version: 2.2.6
150
+ version: 2.0.0
151
151
  required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  requirements:
153
153
  - - ">="