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.
- checksums.yaml +4 -4
- data/README.md +273 -182
- data/lib/local_bus/bus.rb +44 -25
- data/lib/local_bus/message.rb +54 -22
- data/lib/local_bus/publication.rb +31 -0
- data/lib/local_bus/station.rb +111 -150
- data/lib/local_bus/subscriber.rb +19 -8
- data/lib/local_bus/version.rb +1 -1
- data/lib/local_bus.rb +52 -1
- data/sig/generated/local_bus/bus.rbs +83 -0
- data/sig/generated/local_bus/message.rbs +60 -0
- data/sig/generated/local_bus/publication.rbs +20 -0
- data/sig/generated/local_bus/station.rbs +113 -0
- data/sig/generated/local_bus/subscriber.rbs +89 -0
- data/sig/generated/local_bus/version.rbs +5 -0
- data/sig/generated/local_bus.rbs +49 -0
- metadata +25 -18
- data/lib/local_bus/pledge.rb +0 -43
data/lib/local_bus/pledge.rb
DELETED
@@ -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
|