[yast-commit] <rest-service> master : patch.rb - added comments
ref: refs/heads/master commit 299d7e0e17faf9967d658d9ad1d40df32468e29e Author: Ladislav Slezak <lslezak@novell.com> Date: Thu Nov 12 09:54:51 2009 +0100 patch.rb - added comments --- plugins/patches/app/models/patch.rb | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/plugins/patches/app/models/patch.rb b/plugins/patches/app/models/patch.rb index eb868d5..fde6c98 100644 --- a/plugins/patches/app/models/patch.rb +++ b/plugins/patches/app/models/patch.rb @@ -3,8 +3,13 @@ require 'resolvable' # Model for patches available via package kit class Patch < Resolvable + # class variables - they keep the information between requests + # + # currently running patch requests in background (current states) @@running = Hash.new + # finished requests (actual results) @@done = Hash.new + # a mutex which guards access to the shared class variables above @@mutex = Mutex.new def to_xml( options = {} ) @@ -32,6 +37,9 @@ class Patch < Resolvable # find patches # Patch.find(:available) + # Patch.find(:available, :background => true) - read patches in background + # the result may the current state (progress) or the actual patch list + # call this function in a loop until a patch list (or an error) is received # Patch.find(212) def self.find(what, opts = {}) background = opts[:background] @@ -44,6 +52,7 @@ class Patch < Resolvable end if background + # background status bs = nil @@mutex.synchronize do if @@done.has_key?(what) @@ -62,6 +71,7 @@ class Patch < Resolvable end Rails.logger.info "Starting background thread for reading patches..." + # run the patch query in a separate thread Thread.new do res = do_find(what, bs) Rails.logger.info "*** Patches thread: Found #{res.size} applicable patches" -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
Ladislav Slezak