Class: OsCtld::Console::Container
- Inherits:
-
Object
- Object
- OsCtld::Console::Container
- Defined in:
- lib/osctld/console/container.rb
Overview
Instance per container, each holding a list of opened ttys
Instance Attribute Summary collapse
-
#ct ⇒ Object
readonly
Returns the value of attribute ct.
Instance Method Summary collapse
- #add_client(tty_n, io) ⇒ Object
- #close_all ⇒ Object
- #connect_tty0(pid, socket) ⇒ Object
- #expect_tty0(run_conf) ⇒ Object
- #handles_run?(run_conf) ⇒ Boolean
-
#initialize(ct) ⇒ Container
constructor
A new instance of Container.
- #sync ⇒ Object protected
- #tty(n) ⇒ Object
Constructor Details
#initialize(ct) ⇒ Container
Returns a new instance of Container.
6 7 8 9 10 |
# File 'lib/osctld/console/container.rb', line 6 def initialize(ct) @ct = ct @ttys = {} @mutex = Mutex.new end |
Instance Attribute Details
#ct ⇒ Object (readonly)
Returns the value of attribute ct.
4 5 6 |
# File 'lib/osctld/console/container.rb', line 4 def ct @ct end |
Instance Method Details
#add_client(tty_n, io) ⇒ Object
12 13 14 |
# File 'lib/osctld/console/container.rb', line 12 def add_client(tty_n, io) tty(tty_n).add_client(io) end |
#close_all ⇒ Object
46 47 48 49 50 |
# File 'lib/osctld/console/container.rb', line 46 def close_all @mutex.synchronize do @ttys.each_value(&:close) end end |
#connect_tty0(pid, socket) ⇒ Object
16 17 18 |
# File 'lib/osctld/console/container.rb', line 16 def connect_tty0(pid, socket) tty(0).connect(pid, socket) end |
#expect_tty0(run_conf) ⇒ Object
20 21 22 |
# File 'lib/osctld/console/container.rb', line 20 def expect_tty0(run_conf) @mutex.synchronize { @expected_run_conf = run_conf } end |
#handles_run?(run_conf) ⇒ Boolean
24 25 26 27 28 29 30 |
# File 'lib/osctld/console/container.rb', line 24 def handles_run?(run_conf) @mutex.synchronize do next false unless run_conf @expected_run_conf.equal?(run_conf) || @ttys[0]&.handles_run?(run_conf) || false end end |
#sync ⇒ Object (protected)
54 55 56 |
# File 'lib/osctld/console/container.rb', line 54 def sync(&) @mutex.synchronize(&) end |