Class: PbActor::BasicProxy
- Inherits:
-
Object
- Object
- PbActor::BasicProxy
show all
- Defined in:
- lib/pb_actor/basic_proxy.rb
Instance Method Summary
collapse
Constructor Details
#initialize(origin, pid, wr, rd) ⇒ BasicProxy
Returns a new instance of BasicProxy.
5
6
7
8
|
# File 'lib/pb_actor/basic_proxy.rb', line 5
def initialize origin, pid, wr, rd
@origin, @pid, @wr, @rd = origin, pid, wr, rd
@alive = true
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &blk) ⇒ Object
20
21
22
23
|
# File 'lib/pb_actor/basic_proxy.rb', line 20
def method_missing method, *args, &blk
raise ArgumentError, 'actor not support block' if blk
raise DeadActorError, PbActor.dead_actor_msg unless alive?
end
|
Instance Method Details
#alive? ⇒ Boolean
10
11
12
13
14
15
16
17
18
|
# File 'lib/pb_actor/basic_proxy.rb', line 10
def alive?
if !@alive || (!Process.waitpid @pid, Process::WNOHANG)
@alive
else
@alive = false
end
rescue Errno::ECHILD => e
@alive = false
end
|
#to_s ⇒ Object
25
26
27
|
# File 'lib/pb_actor/basic_proxy.rb', line 25
def to_s
"#{self.class}(#{@origin.class})"
end
|