Sha256: 0bff675ef5426f325029d735f21c33810140f581d5fd8cb4489301624f61cae1
Contents?: true
Size: 1.1 KB
Versions: 8
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true require_relative 'thread_pool' module FFI module Libfuse # A JobPool is a ThreadPool whose worker threads are consuming from a Queue class JobPool # Create a Job Pool # @param [Hash<Symbol,Object>] options # @see ThreadPool.new # @param [Proc] worker the unit of work that will be yielded the scheduled jobs def initialize(**options, &worker) @jq = Queue.new @tp = ThreadPool.new(**options) { (args = @jq.pop) && worker.call(*args) } end # Schedule a job # @param [Array<Object>] args # @return [self] def schedule(*args) @jq.push(args) self end alias << schedule alias push schedule # Close the JobPool # @return [self] def close @jq.close self end # Join the JobPool # @return [self] def join(&block) @tp.join(&block) self end # @see ThreadPool#list def list @tp.list end # @see ThreadPool#group def group @tp.group end end end end
Version data entries
8 entries across 8 versions & 1 rubygems