Class: Pione::Front::BasicFront
- Inherits:
-
PioneObject
- Object
- PioneObject
- Pione::Front::BasicFront
- Includes:
- DRbUndumped
- Defined in:
- lib/pione/front/basic-front.rb
Overview
This is base class for all PIONE front classes. PIONE fronts exist in each command and behave as remote interface.
Direct Known Subclasses
BrokerFront, ClientFront, RelayFront, TaskWorkerFront, TupleSpaceProviderFront, TupleSpaceReceiverFront
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
-
#child ⇒ Object
readonly
child process table.
-
#uri ⇒ Object
readonly
front server’s URI string.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, val) ⇒ Object
-
#add_child(pid, front_uri) ⇒ Object
Add child process.
-
#initialize(port) ⇒ BasicFront
constructor
Creates a front server as druby’s service.
-
#pid ⇒ Object
Return PID of the process.
-
#remove_child(pid) ⇒ Object
Delete child process.
-
#terminate ⇒ Object
Terminate the front server.
-
#terminate_command ⇒ Object
Terminate the command.
Constructor Details
#initialize(port) ⇒ BasicFront
Creates a front server as druby’s service.
13 14 15 16 17 |
# File 'lib/pione/front/basic-front.rb', line 13 def initialize(port) @uri = start_service(port, {}) # port is number or range @attrs = {} @child = {} end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
9 10 11 |
# File 'lib/pione/front/basic-front.rb', line 9 def attrs @attrs end |
#child ⇒ Object (readonly)
child process table
10 11 12 |
# File 'lib/pione/front/basic-front.rb', line 10 def child @child end |
#uri ⇒ Object (readonly)
front server’s URI string
8 9 10 |
# File 'lib/pione/front/basic-front.rb', line 8 def uri @uri end |
Instance Method Details
#[](name) ⇒ Object
24 25 26 |
# File 'lib/pione/front/basic-front.rb', line 24 def [](name) @attrs[name] end |
#[]=(name, val) ⇒ Object
28 29 30 |
# File 'lib/pione/front/basic-front.rb', line 28 def []=(name, val) @attrs[name] = val end |
#add_child(pid, front_uri) ⇒ Object
Add child process.
33 34 35 |
# File 'lib/pione/front/basic-front.rb', line 33 def add_child(pid, front_uri) @child[pid] = front_uri end |
#pid ⇒ Object
Return PID of the process.
20 21 22 |
# File 'lib/pione/front/basic-front.rb', line 20 def pid Process.pid end |
#remove_child(pid) ⇒ Object
Delete child process.
38 39 40 |
# File 'lib/pione/front/basic-front.rb', line 38 def remove_child(pid) @child.delete(pid) end |
#terminate ⇒ Object
Terminate the front server. This method assumes to be not called from other process. Note that front servers have no responsibility of killing child processes.
45 46 47 |
# File 'lib/pione/front/basic-front.rb', line 45 def terminate DRb.stop_service end |
#terminate_command ⇒ Object
Terminate the command. This is a nonblocking method because callee process cannot tell its termination to caller, so it returns true immediately.
52 53 54 55 |
# File 'lib/pione/front/basic-front.rb', line 52 def terminate_command Thread.new {Global.command.terminate} return true end |