Class: Thread

Inherits:
Object
  • Object
show all
Defined in:
lib/celluloid/core_ext.rb

Overview

Monkeypatch Thread to allow lazy access to its Celluloid::Mailbox

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#uuid_counterObject

Returns the value of attribute uuid_counter.



5
6
7
# File 'lib/celluloid/core_ext.rb', line 5

def uuid_counter
  @uuid_counter
end

#uuid_limitObject

Returns the value of attribute uuid_limit.



5
6
7
# File 'lib/celluloid/core_ext.rb', line 5

def uuid_limit
  @uuid_limit
end

Class Method Details

.mailboxObject

Retrieve the mailbox for the current thread or lazily initialize it



8
9
10
# File 'lib/celluloid/core_ext.rb', line 8

def self.mailbox
  current[:mailbox] ||= Celluloid::Mailbox.new
end

.receive(timeout = nil, &block) ⇒ Object

Receive a message either as an actor or through the local mailbox



13
14
15
16
17
18
19
# File 'lib/celluloid/core_ext.rb', line 13

def self.receive(timeout = nil, &block)
  if Celluloid.actor?
    Celluloid.receive(timeout, &block)
  else
    mailbox.receive(timeout, &block)
  end
end