Sha256: 1041cf8fa4cb07d90a203669e451bf51e447e42dd5affc52bc8901a81eaa8f63

Contents?: true

Size: 551 Bytes

Versions: 2

Compression:

Stored size: 551 Bytes

Contents

require 'celluloid/fiber'

# Monkeypatch Thread to allow lazy access to its Celluloid::Mailbox
class Thread
  # 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.9.0 lib/celluloid/core_ext.rb
celluloid-0.8.0 lib/celluloid/core_ext.rb