async 0.16.0 → 0.17.0

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: b09ff3d20b66fd1a908bbf44ba04e10fb6b633cf
4
- data.tar.gz: 287bc69ce12fb51c1b1412749ed3fe62473a6673
3
+ metadata.gz: a53fcaec5de211edad59be553e0a79428a6033f6
4
+ data.tar.gz: a3f0c6e234ba5b7e0d31d83e3c4e2d866a9118ed
5
5
  SHA512:
6
- metadata.gz: e3eee05641978320874385017b666d4e7daf02ebc2bfa22ce8eeab6ece962322a645b1e8d6896dc744ef1a428ba48f6f633ad27335dc7573c570ba97ee89bdbb
7
- data.tar.gz: 50f17f1f2213b2afeeb5c0bfe63ed6aae31e98b81d45f9f6bacb1f752808278456ed9e7f19d928d9c7ab459f8ec3f78e638c5bf97a222dee078e6b3fddc0a196
6
+ metadata.gz: 5d3e0bbe7877ef2db58d51d078cfe1c66c93fffa1bcc41d3208766b3b28c48488274e5a3df7d393d982e214a08cfd1d7cf749ad4f939caf217c50c5418782ff8
7
+ data.tar.gz: f3781101e3f0fd51de46d2a4fa9e97369ac88afb4eb0c115d7aaa48f10f7e032309067e0267f55210c07f3ff28d4cd71e368ac556bf886882012ecdfd7bb87fe
data/README.md CHANGED
@@ -81,7 +81,7 @@ This method effectively creates a child task. It's the most efficient way to sch
81
81
 
82
82
  `Async::Reactor` and `Async::Task` form nodes in a tree. Reactors and tasks can spawn children tasks. When you invoke `Async::Reactor#async`, the parent task is determined by calling `Async::Task.current?` which uses fiber local storage. A slightly more efficient method is to use `Async::Task#async`, which uses `self` as the parent task.
83
83
 
84
- When invoking `Async::Reactor#stop`, you will stop *all* children tasks of that reactor. Tasks will raise `Async::Interrupt` if they are in a blocking operation. In addition, it's possible to only stop a sub-tree by issuing `Async::Task#stop`, which will stop that task and all it's children (recursively). When you design a server, you should return the task back to the caller. They can use this task to stop the server if needed, independently of any other unrelated tasks within the reactor, and it will correctly clean up all related tasks.
84
+ When invoking `Async::Reactor#stop`, you will stop *all* children tasks of that reactor. Tasks will raise `Async::Stop` if they are in a blocking operation. In addition, it's possible to only stop a sub-tree by issuing `Async::Task#stop`, which will stop that task and all it's children (recursively). When you design a server, you should return the task back to the caller. They can use this task to stop the server if needed, independently of any other unrelated tasks within the reactor, and it will correctly clean up all related tasks.
85
85
 
86
86
  ### Resource Management
87
87
 
@@ -90,10 +90,10 @@ In order to ensure your resources are cleaned up correctly, make sure you wrap r
90
90
  ```ruby
91
91
  Async::Reactor.run do
92
92
  begin
93
- socket = connect(remote_address) # May raise Async::Interrupt so socket could be nil
93
+ socket = connect(remote_address) # May raise Async::Stop so socket could be nil
94
94
 
95
- socket.write(...) # May raise Async::Interrupt
96
- socket.read(...) # May raise Async::Interrupt
95
+ socket.write(...) # May raise Async::Stop
96
+ socket.read(...) # May raise Async::Stop
97
97
  ensure
98
98
  socket.close if socket
99
99
  end
@@ -26,7 +26,7 @@ require_relative 'condition'
26
26
 
27
27
  module Async
28
28
  # Raised when a task is explicitly stopped.
29
- class Interrupt < Exception
29
+ class Stop < Exception
30
30
  end
31
31
 
32
32
  # A task represents the state associated with the execution of an asynchronous
@@ -74,9 +74,9 @@ module Async
74
74
  @result = yield(self, *args)
75
75
  @status = :complete
76
76
  # Async.logger.debug("Task #{self} completed normally.")
77
- rescue Interrupt
78
- @status = :interrupted
79
- # Async.logger.debug("Task #{self} interrupted: #{$!}")
77
+ rescue Stop
78
+ @status = :stop
79
+ # Async.logger.debug("Task #{self} stopped: #{$!}")
80
80
  rescue Exception => error
81
81
  @result = error
82
82
  @status = :failed
@@ -101,7 +101,7 @@ module Async
101
101
  attr :fiber
102
102
  def_delegators :@fiber, :alive?
103
103
 
104
- # @attr status [Symbol] The status of the execution of the fiber, one of `:running`, `:complete`, `:interrupted`, or `:failed`.
104
+ # @attr status [Symbol] The status of the execution of the fiber, one of `:running`, `:complete`, `:stopped`, or `:failed`.
105
105
  attr :status
106
106
 
107
107
  # Resume the execution of the task.
@@ -144,8 +144,7 @@ module Async
144
144
  @children.each(&:stop)
145
145
 
146
146
  if @fiber.alive?
147
- exception = Interrupt.new("Stop right now!")
148
- @fiber.resume(exception)
147
+ @fiber.resume(Stop.new)
149
148
  end
150
149
  end
151
150
 
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Async
22
- VERSION = "0.16.0"
22
+ VERSION = "0.17.0"
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.16.0
4
+ version: 0.17.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: 2017-06-15 00:00:00.000000000 Z
11
+ date: 2017-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nio4r