ri > Concurrent::ProcessingActor

📘 NAME

Concurrent::ProcessingActor < Synchronization::Object

🚀 Quick Reference

Use CaseCommandDescription
Create an actor with initial valueConcurrent::ProcessingActor.act(initial) { |actor, val| ... }Creates a new processing actor on a shared thread pool
Send a messageactor.tell(message)Sends an asynchronous message to the actor
Receive a messageactor.receive { |msg| ... }Receives a message from the actor's mailbox
Get termination valueactor.termination.valueRetrieves the final value after the actor completes

📖 Description

A new implementation of actor which also simulates the process, therefore it can be used in the same way as Erlang's actors but without occupying thread. A tens of thousands ProcessingActors can run at the same time sharing a thread pool.

💡 Example

# Runs on a pool, does not consume 50_000 threads
actors = 50_000.times.map do |i|
  Concurrent::ProcessingActor.act(i) { |a, i| a.receive.then_on(:fast, i) { |m, i| m + i } }
end

actors.each { |a| a.tell 1 }
values = actors.map(&:termination).map(&:value)
values[0,5]                                        # => [1, 2, 3, 4, 5]
values[-5, 5]                                      # => [49996, 49997, 49998, 49999, 50000]
⚠️ @!macro warn.edge

🔧 Class Methods

🔧 Instance Methods

Concurrent::ProcessingActor
📘 NAME 🚀 Quick Reference 📖 Description
💡 Example
🔧 Class Methods 🔧 Instance Methods

Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-27 16:33 @216.73.216.194
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format