Method: Concurrent::Agent#send
- Defined in:
- lib/concurrent-ruby/concurrent/agent.rb
#send(*args, &action) {|agent, value, *args| ... } ⇒ Boolean
Dispatches an action to the Agent and returns immediately. Subsequently, in a thread from a thread pool, the #value will be set to the return value of the action. Action dispatches are only allowed when the Agent is not #failed?.
The action must be a block/proc/lambda which takes 1 or more arguments. The first argument is the current #value of the Agent. Any arguments passed to the send method via the args parameter will be passed to the action as the remaining arguments. The action must return the new value of the Agent.
-
#send and #send! should be used for actions that are CPU limited
-
#send_off, #send_off!, and #<< are appropriate for actions that may block on IO
-
#send_via and #send_via! are used when a specific executor is to be used for the action
277 278 279 |
# File 'lib/concurrent-ruby/concurrent/agent.rb', line 277 def send(*args, &action) enqueue_action_job(action, args, Concurrent.global_fast_executor) end |