Sha256: 107bf7728e7cb7c7e0ae461a943f92e68d679ac9334015f0720019a6c17b8c6e
Contents?: true
Size: 1.48 KB
Versions: 3
Compression:
Stored size: 1.48 KB
Contents
require 'acfs/service/middleware' module Acfs # @api private # class Runner include Service::Middleware attr_reader :adapter def initialize(adapter) @adapter = adapter @running = false end # Process an operation. Synchronous operations will be run # and parallel operations will be queued. # def process(op) op.synchronous? ? run(op) : enqueue(op) end # Run operation right now skipping queue. # def run(op) op_request(op) { |req| adapter.run req } end # List of current queued operations. # def queue @queue ||= [] end # Enqueue operation to be run later. # def enqueue(op) if running? op_request(op) { |req| adapter.queue req } else queue << op end end # Return true if queued operations are currently processed. # def running? @running end # Start processing queued operations. # def start enqueue_operations @running = true adapter.start rescue queue.clear raise ensure @running = false end def clear queue.clear adapter.abort @running = false end private def enqueue_operations while (op = queue.shift) op_request(op) { |req| adapter.queue req } end end def op_request(op) return if Acfs::Stub.enabled? and Acfs::Stub.stubbed(op) yield prepare op.service.prepare op.request end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
acfs-0.34.1.1.b289 | lib/acfs/runner.rb |
acfs-0.34.1 | lib/acfs/runner.rb |
acfs-0.34.0.1.b288 | lib/acfs/runner.rb |