Sha256: 145490e3bc0084a351658b00955d1e4a03d7b837951650429531d702b6fa90ac
Contents?: true
Size: 1.03 KB
Versions: 6
Compression:
Stored size: 1.03 KB
Contents
module Merb # Keeps track of the status of all currently processing uploads class UploadProgress include DRbUndumped attr_accessor :debug def initialize @guard = Mutex.new @counters = {} end def check(upid) @counters[upid].last rescue nil end def last_checked(upid) @counters[upid].first rescue nil end def update_checked_time(upid) @guard.synchronize { @counters[upid][0] = Time.now } end def add(upid, size) @guard.synchronize do @counters[upid] = [Time.now, {:size => size, :received => 0}] puts "#{upid}: Added" if @debug end end def mark(upid, len) return unless status = check(upid) puts "#{upid}: Marking" if @debug @guard.synchronize { status[:received] = status[:size] - len } end def finish(upid) @guard.synchronize do puts "#{upid}: Finished" if @debug @counters.delete(upid) end end def list @counters.keys.sort end end end
Version data entries
6 entries across 6 versions & 1 rubygems