Sha256: 399362cff9a1f2d1ba6c42f0750e58d3deaf8546c8368971cbac1ae57e3a37fe

Contents?: true

Size: 553 Bytes

Versions: 2

Compression:

Stored size: 553 Bytes

Contents

# frozen_string_literal: true

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

module Trellodon
  module Schedulers
    class Concurrent < Base
      using RubyNext

      DEFAULT_MAX_THREADS = 50

      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.2.1 lib/trellodon/schedulers/concurrent.rb
trellodon-0.2.0 lib/trellodon/schedulers/concurrent.rb