wires 0.1.3 → 0.1.4

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: 0ee0ef4612e829c49c23b2b56726ebfa7b78e0a7
4
- data.tar.gz: 855a4eee6ae3b7c9906876202c23a1503bc1484e
3
+ metadata.gz: 660935c436c6c57687e2c3c8a506d9810e478789
4
+ data.tar.gz: e2cd88acddaade081ca3da917f885e40845d2282
5
5
  SHA512:
6
- metadata.gz: 980b22d9a6bd54663e18c89f3b57c2fcae6d9973f337b2d08035ae17cb3029a2688ef868864955520fd7db8868340dd8368ecac24c3924417a8946edbc91ea1f
7
- data.tar.gz: 4ab9d5b9cc254ebc0b9f33d2988b9c08f1f10a960793132b9ed72fca4a3e3a921293a5792eabbe077b274f717a4a65169aa6c2b712342d045942f6bbd80adcbb
6
+ metadata.gz: addb4f0b4d550fa8e2d45d3124900a9a4a605c65ac05ebf10206bef54bffa23b6666ad4381ba675232e081fa75936e6e63639247f37f17b9c432852fa815477c
7
+ data.tar.gz: 670c122be77ebde3f81e87efb1d1317a526624cddb139c2e9ea9b988f5c1405b1c682b1f6c497c4e79a1b61fc9599b6fe0819a1c4eeaa8394fcaf2fdffb7fb6d
@@ -8,7 +8,11 @@ nil end
8
8
 
9
9
 
10
10
  def fire(event, channel='*')
11
- Channel(channel).fire(event)
11
+ Channel(channel).fire(event, blocking=false)
12
+ nil end
13
+
14
+ def fire_and_wait(event, channel='*')
15
+ Channel(channel).fire(event, blocking=true)
12
16
  nil end
13
17
 
14
18
 
@@ -56,7 +60,7 @@ class Channel
56
60
  nil end
57
61
 
58
62
  # Fire an event on this channel
59
- def fire(_event)
63
+ def fire(_event, blocking=false)
60
64
 
61
65
  # Pull out args from optional array notation
62
66
  _event = [_event] unless _event.is_a? Array
@@ -76,7 +80,7 @@ class Channel
76
80
  for chan in relevant_channels()
77
81
  for target in chan.target_list
78
82
  for string in target[0] & event.class.codestrings
79
- Hub << [string, event, *target[1..-1]]
83
+ Hub << [string, event, blocking, *target[1..-1]]
80
84
  end end end
81
85
 
82
86
  nil end
data/lib/wires/hub.rb CHANGED
@@ -40,11 +40,12 @@ private
40
40
 
41
41
  def self.process_item(x)
42
42
  x, waiting_thread = x
43
- string, event, proc = x
43
+ string, event, blocking, proc = x
44
44
  Thread.new do
45
45
  begin
46
- waiting_thread.wakeup
46
+ waiting_thread.wakeup unless blocking
47
47
  proc.call($event = event)
48
+ waiting_thread.wakeup if blocking
48
49
 
49
50
  rescue Interrupt, SystemExit => e
50
51
  @keepgoing = false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wires
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe McIlvain