Sha256: 462465680633da4f0a299843c170134a5f1d34a768ba143ea76d09832dbf95fa

Contents?: true

Size: 907 Bytes

Versions: 2

Compression:

Stored size: 907 Bytes

Contents

class JFuture < ::BasicObject
  class ExecutorFactory
    @@executor_map = {}
    def self.create(core_pool_size: 20,
          max_pool_size: 20,
          keep_alive_millis: 120000,
          queue_size: 10,
          name: :default,
          thread_factory: DaemonThreadFactory.new)

      work_queue = queue_size.to_i > 0 ?
                    Java::JavaUtilConcurrent::LinkedBlockingQueue.new(queue_size.to_i) :
                    Java::JavaUtilConcurrent::SynchronousQueue.new
      executor = Java::JavaUtilConcurrent::ThreadPoolExecutor.new(
                    core_pool_size.to_i,
                    max_pool_size.to_i,
                    keep_alive_millis.to_i,
                    MILLIS,
                    work_queue,
                    thread_factory)
      @@executor_map[name] = executor
    end

    def self.get_executor(name = :default)
      @@executor_map[name]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
j_future-0.0.2-java lib/j_future/executor_factory.rb
j_future-0.0.1-java lib/j_future/executor_factory.rb