wires 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/wires/hub.rb +1 -1
  3. data/lib/wires/time.rb +10 -7
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc852c0d3cd3cc7571a39f56b081a006d8e704f2
4
- data.tar.gz: 937220faab14ab5bd4da7a0c3cb3877f99e56a76
3
+ metadata.gz: d9c6a74afd25b600883e65a5bb6e54ac1e966eca
4
+ data.tar.gz: 920c223d33dc8128fd0fc7f1b9af13992f5da51e
5
5
  SHA512:
6
- metadata.gz: 4f6f27c768dae1cc9bbf6b93495df61b5165c050f420a86317fc732aa8b670443a3b9d62ad5a7c1ae07e45c23267e6ad9b2b6e015beb2f708819896d1593ab66
7
- data.tar.gz: d8b45765b30d6e690f5a4c6d49d3832a1e41f0b8d4f9bd2c8cb4cde7179a6db3ff62537a42266ede277cc689b9243d70c491f0930a7a364df020d1aa4921a7a1
6
+ metadata.gz: 18d14b246f4f015b56e8fe9d0122201ecd27f6627764c62b814b1683aedfb705c5d1fb5b101432ec1f42a7dbdf0047916287d112a7555c94b81e851a478fe0e7
7
+ data.tar.gz: ea363328dceda12c2c2b933be15018ddf16dd84125232718c7189c9a81562d01664dcf884b9ef31bdd0ba2eb3f333608a82c565f9f03eb9f9743dc4229ee26c5
data/lib/wires/hub.rb CHANGED
@@ -184,7 +184,7 @@ class Hub
184
184
  @child_threads << Thread.new do
185
185
  begin
186
186
  waiting_thread.wakeup unless blocking or not waiting_thread
187
- proc.call($event = event)
187
+ proc.call(event)
188
188
  waiting_thread.wakeup if blocking and waiting_thread
189
189
 
190
190
  rescue Interrupt, SystemExit => e
data/lib/wires/time.rb CHANGED
@@ -6,9 +6,10 @@ class TimeSchedulerAnonEvent < TimeSchedulerEvent; end
6
6
 
7
7
  # A singleton class to schedule future firing of events
8
8
  class TimeScheduler
9
- @schedule = Array.new
10
- @schedule_lock = Mutex.new
11
- @thread = Thread.new {nil}
9
+ @schedule = Array.new
10
+ @schedule_lock = Mutex.new
11
+ @thread = Thread.new {nil}
12
+ @keepgoing_lock = Mutex.new
12
13
 
13
14
  # Operate on the metaclass as a type of singleton pattern
14
15
  class << self
@@ -66,8 +67,8 @@ class TimeScheduler
66
67
  # Calculate the time to sleep based on next event's time
67
68
  if on_deck
68
69
  sleep [(on_deck[:time]-Time.now), 0].max
69
- else
70
- sleep # sleep until wakeup if no event is on deck
70
+ else # sleep until wakeup if no event is on deck
71
+ sleep if @keepgoing
71
72
  end
72
73
 
73
74
  end
@@ -84,8 +85,10 @@ class TimeScheduler
84
85
 
85
86
  # Stop the main loop upon death of Hub
86
87
  Hub.before_kill(retain:true) do
87
- @keepgoing=false
88
- @thread.wakeup
88
+ @keepgoing_lock.synchronize do
89
+ @keepgoing=false
90
+ @thread.wakeup
91
+ end
89
92
  sleep 0
90
93
  end
91
94
  # Refire the start event after Hub dies in case it restarts
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wires
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe McIlvain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-30 00:00:00.000000000 Z
11
+ date: 2013-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport