hegemon 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hegemon.rb +20 -9
- 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: a167a9bc4711dc205fcebe150e328cbda3c0df16
|
4
|
+
data.tar.gz: 5f24fa3dfe4dd37a911d37d05e82e1bc26535d0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 878c9a6e4b66597806d9cdc4943a178542eccd0c4e93a2f12ccfd9f03263e81039096515ec2e7d081e1c0bed5b6116b4868a6b079c8a01338dd74b8384e753db
|
7
|
+
data.tar.gz: 1212f88744fa2bafce52df032008a1ffa0f9cc8ff6075ec06fe6dd33679d8e203566168aa0d253d1442217b2523f09d5d768136e51a3a65ea76403cc57de310a
|
data/lib/hegemon.rb
CHANGED
@@ -182,10 +182,14 @@ module Hegemon
|
|
182
182
|
# [+state+]
|
183
183
|
# The symbol to compare against the current state against
|
184
184
|
#
|
185
|
+
|
185
186
|
def block_until_state(s); # :args: state
|
186
187
|
raise ArgumentError, "Cannot block until undefined state :#{s}" \
|
187
188
|
unless @_hegemon_states.keys.include? s
|
188
|
-
|
189
|
+
|
190
|
+
@_hegemon_transition_lock ||= Monitor.new
|
191
|
+
sleep 0 until @_hegemon_transition_lock.synchronize { @_hegemon_state==s }
|
192
|
+
|
189
193
|
nil end
|
190
194
|
|
191
195
|
#
|
@@ -233,7 +237,7 @@ module Hegemon
|
|
233
237
|
or (not @_hegemon_auto_thread.status)
|
234
238
|
|
235
239
|
@_end_hegemon_auto_thread = false
|
236
|
-
@_hegemon_auto_thread_throttle
|
240
|
+
@_hegemon_auto_thread_throttle = throttle
|
237
241
|
@_hegemon_auto_thread = Thread.new do
|
238
242
|
i = 0
|
239
243
|
until @_end_hegemon_auto_thread
|
@@ -315,6 +319,11 @@ class HegemonTransition
|
|
315
319
|
@src_state = src_state
|
316
320
|
@dest_state = dest_state
|
317
321
|
|
322
|
+
@object.instance_variable_set(:@_hegemon_transition_lock,
|
323
|
+
(@transition_lock = Monitor.new)) \
|
324
|
+
unless (@transition_lock = @object.instance_variable_get( \
|
325
|
+
:@_hegemon_transition_lock))
|
326
|
+
|
318
327
|
@conditions = []
|
319
328
|
@sufficients = []
|
320
329
|
@requirements = []
|
@@ -359,13 +368,15 @@ class HegemonTransition
|
|
359
368
|
private
|
360
369
|
|
361
370
|
def perform
|
362
|
-
@
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
371
|
+
@transition_lock.synchronize do
|
372
|
+
@progress = :pre
|
373
|
+
procs_run(@befores)
|
374
|
+
@progress = :impose
|
375
|
+
@object.impose_state(@dest_state)
|
376
|
+
@progress = :post
|
377
|
+
procs_run(@afters)
|
378
|
+
@progress = nil
|
379
|
+
end
|
369
380
|
nil end
|
370
381
|
|
371
382
|
def procs_run(list)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hegemon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
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-07-
|
11
|
+
date: 2013-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: threadlock
|