async 1.29.0 → 1.29.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
  SHA256:
3
- metadata.gz: 421b9e871d367ee3c769c4f7a9f3e51125d5e11c45d37f9d8c562a33ecce70ed
4
- data.tar.gz: 868be7ef14d83fb04620c862d69b38e03f0b5ba036cd2d65e6caf0f45c58a689
3
+ metadata.gz: 94443a93442232e8189364cd931084a0cf188a9adea3fe91287f192fed44fc2e
4
+ data.tar.gz: cec386ffc8948123aeb771866d639b9e49a66cdb8e32fa42e15f07bbd06bd78e
5
5
  SHA512:
6
- metadata.gz: 47620eaf32dc53e1978f3c07ef66823c6aa4b3e85ec23ac3a207d1cdb39a06c790428a9b67dc3b955b74edf723faa567b2f8a077893ecf0c3d1383c5c62997e0
7
- data.tar.gz: 74e3b0e17cc0d8f63bdc2c7e4aa40033062a07d2a5a1866f3ca3ac072376264463f8b11203485a07bbed11c475cbad6a2ac81f9297e900a732263f8b7b0b401b
6
+ metadata.gz: 3cf4de1694de02a5c291b124d1ee62020b8ab8997a1e951977e6450a526d00a236918af520e1e0c4e63036c50731a07932d734b8a1f4b825f17661cb30f23e0f
7
+ data.tar.gz: 0c157b4af9bdd4a3ade74ccc12a4f2ea79162d45395d28e34c30e2d7cb7535b9137d37ed0688852b0b52834cf38c7a4207b11797deaa201d08d227c4a6e714ce
data/lib/async/node.rb CHANGED
@@ -302,8 +302,31 @@ module Async
302
302
  end
303
303
  end
304
304
 
305
- def stop
306
- @children&.each(&:stop)
305
+ # Immediately terminate all children tasks, including transient tasks.
306
+ # Internally invokes `stop(false)` on all children.
307
+ def terminate
308
+ # Attempt to stop the current task immediately, and all children:
309
+ stop(false)
310
+
311
+ # If that doesn't work, take more serious action:
312
+ @children&.each do |child|
313
+ child.terminate
314
+ end
315
+ end
316
+
317
+ # Attempt to stop the current node immediately, including all non-transient children.
318
+ # Invokes {#stop_children} to stop all children.
319
+ # @parameter later [Boolean] Whether to defer stopping until some point in the future.
320
+ def stop(later = false)
321
+ # The implementation of this method may defer calling `stop_children`.
322
+ stop_children(later)
323
+ end
324
+
325
+ # Attempt to stop all non-transient children.
326
+ private def stop_children(later = false)
327
+ @children&.each do |child|
328
+ child.stop(later) unless child.transient?
329
+ end
307
330
  end
308
331
 
309
332
  def print_hierarchy(out = $stdout, backtrace: true)
data/lib/async/reactor.rb CHANGED
@@ -293,32 +293,23 @@ module Async
293
293
  Console.logger.debug(self) {"Exiting run-loop because #{$! ? $! : 'finished'}."}
294
294
  end
295
295
 
296
- def stop(later = true)
297
- @children&.each do |child|
298
- # We don't want this process to propagate `Async::Stop` exceptions, so we schedule tasks to stop later.
299
- child.stop(later)
300
- end
301
- end
302
-
303
296
  # Stop each of the children tasks and close the selector.
304
- #
305
- # @return [void]
306
297
  def close
307
- # This is a critical step. Because tasks could be stored as instance variables, and since the reactor is (probably) going out of scope, we need to ensure they are stopped. Otherwise, the tasks will belong to a reactor that will never run again and are not stopped.
308
- self.stop(false)
298
+ # This is a critical step. Because tasks could be stored as instance variables, and since the reactor is (probably) going out of scope, we need to ensure they are stopped. Otherwise, the tasks will belong to a reactor that will never run again and are not stopped:
299
+ self.terminate
309
300
 
310
301
  @selector.close
311
302
  @selector = nil
312
303
  end
313
304
 
314
305
  # Check if the selector has been closed.
315
- # @return [Boolean]
306
+ # @returns [Boolean]
316
307
  def closed?
317
308
  @selector.nil?
318
309
  end
319
310
 
320
311
  # Put the calling fiber to sleep for a given ammount of time.
321
- # @param duration [Numeric] The time in seconds, to sleep for.
312
+ # @parameter duration [Numeric] The time in seconds, to sleep for.
322
313
  def sleep(duration)
323
314
  fiber = Fiber.current
324
315
 
data/lib/async/task.rb CHANGED
@@ -156,7 +156,6 @@ module Async
156
156
  # Soon to become attr :result
157
157
 
158
158
  # Stop the task and all of its children.
159
- # @return [void]
160
159
  def stop(later = false)
161
160
  if self.stopped?
162
161
  # If we already stopped this task... don't try to stop it again:
@@ -250,9 +249,7 @@ module Async
250
249
  # logger.debug(self) {"Task was stopped with #{@children&.size.inspect} children!"}
251
250
  @status = :stopped
252
251
 
253
- @children&.each do |child|
254
- child.stop(true)
255
- end
252
+ stop_children(true)
256
253
  end
257
254
 
258
255
  def make_fiber(&block)
data/lib/async/version.rb CHANGED
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Async
24
- VERSION = "1.29.0"
24
+ VERSION = "1.29.1"
25
25
  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.29.0
4
+ version: 1.29.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: 2021-04-10 00:00:00.000000000 Z
11
+ date: 2021-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: console
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  requirements: []
182
- rubygems_version: 3.2.3
182
+ rubygems_version: 3.2.15
183
183
  signing_key:
184
184
  specification_version: 4
185
185
  summary: A concurrency framework for Ruby.