Sha256: c07fee849c973a384061564449fc27b1c41c7ea5a40a2557e4f5ec419791fe49

Contents?: true

Size: 577 Bytes

Versions: 1

Compression:

Stored size: 577 Bytes

Contents

require 'timeout'

module PbActor
  class BasicProxy
    def initialize origin, pid, wr, rd
      @origin, @pid, @wr, @rd = origin, pid, wr, rd
    end

    def alive?
      # Have any other way to check a process status?
      !timeout(0.001){@rd.eof?}
    rescue Timeout::Error => e
      true
    end

    def method_missing method, *args, &blk
      raise ArgumentError, 'actor not support block' if blk
      raise DeadActorError, 'dead actor call' unless alive?
    end

    def to_s
      "#{self.class}(#{@origin.class})"
    end

    undef send, public_send
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pb_actor-0.0.3 lib/pb_actor/basic_proxy.rb