async-tools 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/async/bus/bus.rb +4 -2
- data/lib/async/channel.rb +1 -1
- data/lib/async/timer.rb +5 -4
- data/lib/async/tools/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 076d4f7b65287933136f3f2f05417e77dcd548bbe1eb9bfb475eff44b6003891
|
4
|
+
data.tar.gz: 18c1b63f416d4890b7696a3a3ba94de0e8cb0df7ccb6e115fe328127f7f93e9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a32fb5123b0d520ffd436e07b2003b116f9e3883b386048bb24e4b1327fbcb8de593573a8b00170859c0fef6c18f880ad79d7d78d77dd0446355d55c9ec2545
|
7
|
+
data.tar.gz: 918a7bfb836f8a4725dc2b7869aaa4879a74918267cfb7c9cf07a9d73a218a626bed0d75f83373dd008ad59ebce7273949364ac27471cda4ab8e395cd1c678e9
|
data/Gemfile.lock
CHANGED
data/lib/async/bus/bus.rb
CHANGED
@@ -5,9 +5,11 @@ class Async::Bus::Bus
|
|
5
5
|
|
6
6
|
include Console
|
7
7
|
|
8
|
-
def initialize(name: :default, limit: 10)
|
8
|
+
def initialize(name: :default, limit: 10, parent: Async::Task.current)
|
9
9
|
@name = name
|
10
10
|
@limit = limit
|
11
|
+
@parent = parent
|
12
|
+
|
11
13
|
@closed = false
|
12
14
|
|
13
15
|
@subscribers = Hash.new { |hash, key| hash[key] = [] }
|
@@ -43,7 +45,7 @@ class Async::Bus::Bus
|
|
43
45
|
serve(chan, event_name, callable)
|
44
46
|
end
|
45
47
|
|
46
|
-
def async_subscribe(*, **, &) =
|
48
|
+
def async_subscribe(*, **, &) = @parent.async { subscribe(*, **, &) }
|
47
49
|
def on_event(&block) = @on_event_callback = block
|
48
50
|
|
49
51
|
def close
|
data/lib/async/channel.rb
CHANGED
data/lib/async/timer.rb
CHANGED
@@ -7,20 +7,21 @@ class Async::Timer
|
|
7
7
|
|
8
8
|
class AlreadyStarted < Error; end
|
9
9
|
|
10
|
-
def initialize(delay, repeat: true, start: true, run_on_start: false, parent: Async::Task.current, &block)
|
11
|
-
|
10
|
+
def initialize(delay, repeat: true, start: true, run_on_start: false, parent: Async::Task.current, call: nil, &block) # rubocop:disable Metrics/ParameterLists
|
11
|
+
callables = [call, block]
|
12
|
+
raise ArgumentError, "either block or call: must be given" if callables.all?(&:nil?) || callables.none?(&:nil?)
|
12
13
|
|
13
14
|
@delay = delay
|
14
15
|
@repeat = repeat
|
15
16
|
@run_on_start = run_on_start
|
16
17
|
@parent = parent
|
17
|
-
@
|
18
|
+
@callable = call || block
|
18
19
|
|
19
20
|
self.start if start
|
20
21
|
end
|
21
22
|
|
22
23
|
def stop = @task.stop
|
23
|
-
def call = @
|
24
|
+
def call = @callable.call
|
24
25
|
|
25
26
|
def active? = @active
|
26
27
|
|
data/lib/async/tools/version.rb
CHANGED