Class: Concurrent::Actors::Actor
- Inherits:
-
Object
- Object
- Concurrent::Actors::Actor
- Defined in:
- lib/concurrent/actors/actor.rb,
lib/concurrent/actors/mailbox.rb
Defined Under Namespace
Classes: Mailbox
Class Method Summary collapse
- .current ⇒ Object
- .current_mailbox ⇒ Object
- .receive(timeout = nil, &prc) ⇒ Object
- .spawn(&prc) ⇒ Object (also: new)
Instance Method Summary collapse
- #<<(value) ⇒ Object
-
#initialize(mailbox) ⇒ Actor
constructor
A new instance of Actor.
Constructor Details
#initialize(mailbox) ⇒ Actor
Returns a new instance of Actor.
72 73 74 |
# File 'lib/concurrent/actors/actor.rb', line 72 def initialize(mailbox) @mailbox = mailbox end |
Class Method Details
.current ⇒ Object
58 59 60 |
# File 'lib/concurrent/actors/actor.rb', line 58 def current Thread.current[:__current_actor__] ||= private_new(current_mailbox) end |
.current_mailbox ⇒ Object
62 63 64 |
# File 'lib/concurrent/actors/actor.rb', line 62 def current_mailbox Thread.current[:__current_mailbox__] ||= Mailbox.new end |
.receive(timeout = nil, &prc) ⇒ Object
67 68 69 |
# File 'lib/concurrent/actors/actor.rb', line 67 def receive(timeout=nil, &prc) current_mailbox.receive(timeout, &prc) end |
Instance Method Details
#<<(value) ⇒ Object
76 77 78 79 |
# File 'lib/concurrent/actors/actor.rb', line 76 def <<(value) @mailbox << value self end |