Sha256: 95153c333556febf2660c8646910ea91c2337c6d7b6d4e82134037a1ebb5fc5e

Contents?: true

Size: 552 Bytes

Versions: 2

Compression:

Stored size: 552 Bytes

Contents

# frozen_string_literal: true

require "trellodon/schedulers/base"
require "concurrent"

module Trellodon
  module Schedulers
    class Concurrent < Base
      using RubyNext

      DEFAULT_MAX_THREADS = 4

      attr_reader :max_threads

      def initialize(threads_count = DEFAULT_MAX_THREADS)
        @max_threads = threads_count
      end

      def post(&block)
        ::Concurrent::Future.execute(executor:, &block)
      end

      private

      def executor
        ::Concurrent::FixedThreadPool.new(max_threads)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trellodon-0.4.0 lib/trellodon/schedulers/concurrent.rb
trellodon-0.3.0 lib/trellodon/schedulers/concurrent.rb