Sha256: a5e3cdafc5d5fb759ddb4db47b4d0f11362f614cadf34640ef76a22d5498761b

Contents?: true

Size: 595 Bytes

Versions: 2

Compression:

Stored size: 595 Bytes

Contents

require 'celluloid/fiber'

# Monkeypatch Thread to allow lazy access to its Celluloid::Mailbox
class Thread
  attr_accessor :uuid_counter, :uuid_limit

  # Retrieve the mailbox for the current thread or lazily initialize it
  def self.mailbox
    current[:mailbox] ||= Celluloid::Mailbox.new
  end

  # Receive a message either as an actor or through the local mailbox
  def self.receive(&block)
    if Celluloid.actor?
      Celluloid.receive(&block)
    else
      mailbox.receive(&block)
    end
  end
end

class Fiber
  # Celluloid::Task associated with this Fiber
  attr_accessor :task
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
celluloid-0.10.0 lib/celluloid/core_ext.rb
celluloid-0.9.1 lib/celluloid/core_ext.rb