Method: Concurrent::ThreadPoolExecutor#post

Defined in:
lib/concurrent-ruby/concurrent/executor/thread_pool_executor.rb

#post(*args) { ... } ⇒ Boolean

Submit a task to the executor for asynchronous processing.

Parameters:

  • args (Array)

    zero or more arguments to be passed to the task

Yields:

  • the asynchronous task to perform

Returns:

  • (Boolean)

    ‘true` if the task is queued, `false` if the executor is not running

Raises:

  • (ArgumentError)

    if no task is given



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/concurrent-ruby/concurrent/executor/thread_pool_executor.rb', line 56

class ThreadPoolExecutor < ThreadPoolExecutorImplementation

  # @!macro thread_pool_executor_method_initialize
  #
  #   Create a new thread pool.
  #
  #   @param [Hash] opts the options which configure the thread pool.
  #
  #   @option opts [Integer] :max_threads (DEFAULT_MAX_POOL_SIZE) the maximum
  #     number of threads to be created
  #   @option opts [Integer] :min_threads (DEFAULT_MIN_POOL_SIZE) When a new task is submitted
  #      and fewer than `min_threads` are running, a new thread is created
  #   @option opts [Integer] :idletime (DEFAULT_THREAD_IDLETIMEOUT) the maximum
  #     number of seconds a thread may be idle before being reclaimed
  #   @option opts [Integer] :max_queue (DEFAULT_MAX_QUEUE_SIZE) the maximum
  #     number of tasks allowed in the work queue at any one time; a value of
  #     zero means the queue may grow without bound
  #   @option opts [Symbol] :fallback_policy (:abort) the policy for handling new
  #     tasks that are received when the queue size has reached
  #     `max_queue` or the executor has shut down
  #   @option opts [Boolean] :synchronous (DEFAULT_SYNCHRONOUS) whether or not a value of 0
  #     for :max_queue means the queue must perform direct hand-off rather than unbounded.
  #   @raise [ArgumentError] if `:max_threads` is less than one
  #   @raise [ArgumentError] if `:min_threads` is less than zero
  #   @raise [ArgumentError] if `:fallback_policy` is not one of the values specified
  #     in `FALLBACK_POLICIES`
  #
  #   @see http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html

  # @!method initialize(opts = {})
  #   @!macro thread_pool_executor_method_initialize
end