local_bus 0.1.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # rbs_inline: enabled
4
-
5
- class LocalBus
6
- # A promise-like object that wraps an Async::Barrier and a list of Subscribers.
7
- # Delegates #wait to the barrier and all other methods to the subscriber list.
8
- class Pledge
9
- # Constructor
10
- # @rbs barrier: Async::Barrier -- barrier used to wait for all tasks
11
- # @rbs subscribers: Array[Subscriber]
12
- def initialize(barrier, *subscribers)
13
- @barrier = barrier
14
- @subscribers = subscribers
15
- end
16
-
17
- # Blocks and waits for the barrier... all subscribers to complete
18
- # @rbs return: void
19
- def wait
20
- @barrier.wait
21
- self
22
- end
23
-
24
- # Blocks and waits then returns all subscribers
25
- # @rbs return: Array[Subscriber]
26
- def value
27
- wait
28
- @subscribers
29
- end
30
-
31
- ## @!group Delegatation to subscribers
32
-
33
- # def method_missing(...)
34
- # return @subscribers.send(...) if @subscribers.respond_to?(...)
35
- # super
36
- # end
37
-
38
- # def respond_to_missing?(...)
39
- # return true if @subscribers.respond_to?(...)
40
- # super
41
- # end
42
- end
43
- end