Sha256: 644312c5c2332686e6ee31140ad3d8bf1f7ec4e3e887866f315ddc0ecf0248d8

Contents?: true

Size: 561 Bytes

Versions: 2

Compression:

Stored size: 561 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: 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/.rbnext/3.1/trellodon/schedulers/concurrent.rb
trellodon-0.3.0 lib/.rbnext/3.1/trellodon/schedulers/concurrent.rb