# 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