Sha256: 3e710256f310fa66bbc538eb3796ec5b4011bcfa13697edddfa5b38a671e9c85

Contents?: true

Size: 628 Bytes

Versions: 3

Compression:

Stored size: 628 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(timeout = nil, &block)
    if Celluloid.actor?
      Celluloid.receive(timeout, &block)
    else
      mailbox.receive(timeout, &block)
    end
  end
end

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

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
celluloid-0.11.1 lib/celluloid/core_ext.rb
celluloid-0.11.0 lib/celluloid/core_ext.rb
kulesa-celluloid-0.10.2 lib/celluloid/core_ext.rb