Sha256: 5b30e2148f6628abc1a2ae54db08400d859ffd5c9ef76d47ce38bac5d37ac3d4

Contents?: true

Size: 646 Bytes

Versions: 1

Compression:

Stored size: 646 Bytes

Contents

require 'timeout'

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

    def alive?
      if !@alive || (!Process.waitpid @pid, Process::WNOHANG)
        @alive
      else
        @alive = false
      end
    rescue Errno::ECHILD => e
      @alive = false
    end

    def method_missing method, *args, &blk
      raise ArgumentError, 'actor not support block' if blk
      raise DeadActorError, PbActor.dead_actor_msg 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.5 lib/pb_actor/basic_proxy.rb