wires 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wires/hub.rb +1 -1
- data/lib/wires/time.rb +10 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9c6a74afd25b600883e65a5bb6e54ac1e966eca
|
4
|
+
data.tar.gz: 920c223d33dc8128fd0fc7f1b9af13992f5da51e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
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
|
10
|
-
@schedule_lock
|
11
|
-
@thread
|
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
|
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
|
-
@
|
88
|
-
|
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.
|
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-
|
11
|
+
date: 2013-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|