hegemon 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hegemon.rb +16 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a167a9bc4711dc205fcebe150e328cbda3c0df16
4
- data.tar.gz: 5f24fa3dfe4dd37a911d37d05e82e1bc26535d0c
3
+ metadata.gz: 6c86bd9b37d2df2008cac937d1ab4e7bfd5d5276
4
+ data.tar.gz: 6c8876f0111431d8d89bd15ef7761b69a1717186
5
5
  SHA512:
6
- metadata.gz: 878c9a6e4b66597806d9cdc4943a178542eccd0c4e93a2f12ccfd9f03263e81039096515ec2e7d081e1c0bed5b6116b4868a6b079c8a01338dd74b8384e753db
7
- data.tar.gz: 1212f88744fa2bafce52df032008a1ffa0f9cc8ff6075ec06fe6dd33679d8e203566168aa0d253d1442217b2523f09d5d768136e51a3a65ea76403cc57de310a
6
+ metadata.gz: c1d76a913eb1d7a6dfa6de164164b421a7ceb2e7a2dbc973541414e30920eb83b43066785b42c6428c63f9ec32aea9c50deb25dac02271947fbec66c9f0ae00d
7
+ data.tar.gz: 1a04f028f986810d9b63edbd07812c2f80822cd0b116e1d5543ad35fd9ad8fc4a9686fa961c2f937bbd1765a77612360bf093212eedcd830d04da3374ed5a2d8
@@ -181,9 +181,11 @@ module Hegemon
181
181
  #
182
182
  # [+state+]
183
183
  # The symbol to compare against the current state against
184
+ # [+throttle = 0+]
185
+ # The amount of time to sleep between state checks, 0 by default.
184
186
  #
185
187
 
186
- def block_until_state(s); # :args: state
188
+ def block_until_state(s, throttle = 0); # :args: state, throttle = 0
187
189
  raise ArgumentError, "Cannot block until undefined state :#{s}" \
188
190
  unless @_hegemon_states.keys.include? s
189
191
 
@@ -229,21 +231,25 @@ module Hegemon
229
231
  # counting up from +0+ the value passed to do_state_tasks, until the
230
232
  # thread is stopped with end_hegemon_auto_thread\.
231
233
  #
232
- # [+throttle = 0.1+]
233
- # The amount of time to sleep between iterations, 0.1 seconds by default.
234
+ # [+throttle = nil+]
235
+ # The amount of time to sleep between iterations.
236
+ # If left as nil, the last given throttle value is used.
237
+ # The default throttle value is 0.05 seconds.
234
238
  #
235
- def start_hegemon_auto_thread(throttle = 0.1)
239
+ def start_hegemon_auto_thread(throttle = nil)
236
240
  if (not @_hegemon_auto_thread) \
237
241
  or (not @_hegemon_auto_thread.status)
238
242
 
239
243
  @_end_hegemon_auto_thread = false
240
- @_hegemon_auto_thread_throttle = throttle
244
+ @_hegemon_auto_thread_throttle ||= throttle
245
+ @_hegemon_auto_thread_throttle ||= 0.05
241
246
  @_hegemon_auto_thread = Thread.new do
242
247
  i = 0
243
248
  until @_end_hegemon_auto_thread
244
249
  iter_hegemon_auto_loop(i)
245
250
  i += 1
246
- sleep @_hegemon_auto_thread_throttle
251
+ sleep @_hegemon_auto_thread_throttle \
252
+ unless @_end_hegemon_auto_thread
247
253
  end
248
254
  end
249
255
  end
@@ -262,6 +268,8 @@ module Hegemon
262
268
  #
263
269
  def end_hegemon_auto_thread
264
270
  @_end_hegemon_auto_thread = true
271
+ @_hegemon_auto_thread.join unless @_hegemon_auto_thread==Thread.current
272
+ @_hegemon_auto_thread = nil
265
273
  end
266
274
  threadlock :end_hegemon_auto_thread, :lock=>:@_hegemon_lock
267
275
 
@@ -290,6 +298,8 @@ class HegemonState
290
298
  end
291
299
 
292
300
  def task(&block); @tasks << block if block; end
301
+ def setup_task(&block) #TODO
302
+ end
293
303
 
294
304
  def transition_to(state, &block)
295
305
  @transitions[state] = HegemonTransition.new(@object, @state, state, &block)
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.6
4
+ version: 0.0.7
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-08 00:00:00.000000000 Z
11
+ date: 2013-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: threadlock