diff options
author | hut <hut@lavabit.com> | 2009-06-11 21:32:40 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-06-11 21:32:40 +0200 |
commit | 41fddc99de7878ff7d90fafcb120003d0dc2c0d9 (patch) | |
tree | eb9cde32d67bea7418a73316f0ee1d06fe0de645 /code/scheduler.rb | |
parent | cea26b6d270526ffc241d8a38b1f27188a8868c3 (diff) | |
download | ranger-41fddc99de7878ff7d90fafcb120003d0dc2c0d9.tar.gz |
mooo
Diffstat (limited to 'code/scheduler.rb')
-rw-r--r-- | code/scheduler.rb | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/code/scheduler.rb b/code/scheduler.rb index 3644f681..9b716d2f 100644 --- a/code/scheduler.rb +++ b/code/scheduler.rb @@ -12,22 +12,24 @@ module Scheduler @active = false @thread ||= Thread.new do -# Thread.current.priority = PRIORITY - while true - sleep 0.1 - if @active and not @scheduled.empty? - while dir = @scheduled.shift - dir.refresh(true) - dir.resize - force_update - end + if EVIL + Thread.current.priority = PRIORITY + while true + Thread.stop + manage unless @scheduled.empty? or !@active + end + + else + while true + sleep 0.1 + manage unless @scheduled.empty? or !@active end end end end def run - @active = true +# @active = true end def stop @@ -36,20 +38,25 @@ module Scheduler def <<(dir) dir.scheduled = true - unless include? dir + unless @scheduled.include? dir @scheduled << dir + if EVIL + @thread.run + end end end - def include?(dir) - @scheduled.include?(dir) + private + def manage + while dir = @scheduled.shift + dir.refresh(true) + dir.resize + force_update + end end def force_update Process.kill( UPDATE_SIGNAL, PID ) end - -# def priority() @thread.priority end -# def priority=(x) @thread.priority=(x) end - end + |