Class: Net::SSH::Connection::Channel
- Inherits:
-
Object
- Object
- Net::SSH::Connection::Channel
- Defined in:
- lib/net-ssh-open3.rb
Overview
All methods in this class were created for private use of Net::SSH::Open3. You probably won’t need to call them directly.
Instance Attribute Summary collapse
-
#open3_close_semaphore ⇒ Object
readonly
A semaphore to flag this channel as closed.
-
#open3_exception ⇒ Object
readonly
An exception tracked during channel opening, if any.
-
#open3_waiter_thread ⇒ Object
Waiter thread that watches this channel.
Instance Method Summary collapse
-
#do_close(*args) ⇒ Object
Overridden version of
do_closewhich tracks exceptions and sync. -
#do_open_confirmation(*args) ⇒ Object
Overridden version of
do_open_confirmationwhich tracks exceptions. -
#do_open_failed(*args) ⇒ Object
Overridden version of
do_open_failedwhich tracks exceptions and sync. -
#initialize(*args, &block) ⇒ Channel
constructor
Overridden version of
initializewhich creates synchronization objects. -
#open3_signal_close ⇒ Object
Flag this channel as closed and deliver signals.
-
#open3_signal_open ⇒ Object
Flag this channel as opened and deliver signals.
-
#open3_wait_open ⇒ Object
Suspend current thread execution until this channel is opened.
-
#wait ⇒ Object
Wait for this channel to be closed.
Constructor Details
#initialize(*args, &block) ⇒ Channel
Overridden version of initialize which creates synchronization objects.
501 502 503 504 505 506 507 |
# File 'lib/net-ssh-open3.rb', line 501 def initialize(*args, &block) initialize_without_open3(*args, &block) @open3_close_semaphore = ConditionVariable.new @open3_open_mutex = Mutex.new @open3_open_semaphore = ConditionVariable.new end |
Instance Attribute Details
#open3_close_semaphore ⇒ Object (readonly)
A semaphore to flag this channel as closed.
491 492 493 |
# File 'lib/net-ssh-open3.rb', line 491 def open3_close_semaphore @open3_close_semaphore end |
#open3_exception ⇒ Object (readonly)
An exception tracked during channel opening, if any.
494 495 496 |
# File 'lib/net-ssh-open3.rb', line 494 def open3_exception @open3_exception end |
#open3_waiter_thread ⇒ Object
Waiter thread that watches this channel.
497 498 499 |
# File 'lib/net-ssh-open3.rb', line 497 def open3_waiter_thread @open3_waiter_thread end |
Instance Method Details
#do_close(*args) ⇒ Object
Overridden version of do_close which tracks exceptions and sync.
511 512 513 514 515 516 517 |
# File 'lib/net-ssh-open3.rb', line 511 def do_close(*args) do_close_without_open3(*args) rescue @open3_exception = $! ensure open3_signal_close end |
#do_open_confirmation(*args) ⇒ Object
Overridden version of do_open_confirmation which tracks exceptions.
521 522 523 524 525 526 |
# File 'lib/net-ssh-open3.rb', line 521 def do_open_confirmation(*args) do_open_confirmation_without_open3(*args) # Do not signal right now: we will signal as soon as PID arrives. rescue @open3_exception = $! end |
#do_open_failed(*args) ⇒ Object
Overridden version of do_open_failed which tracks exceptions and sync.
530 531 532 533 534 535 536 537 |
# File 'lib/net-ssh-open3.rb', line 530 def do_open_failed(*args) do_open_failed_without_open3(*args) rescue @open3_exception = $! ensure open3_signal_open open3_signal_close end |
#open3_signal_close ⇒ Object
Flag this channel as closed and deliver signals. Should be called from within session’s mutex.
565 566 567 |
# File 'lib/net-ssh-open3.rb', line 565 def open3_signal_close @open3_close_semaphore.signal end |
#open3_signal_open ⇒ Object
Flag this channel as opened and deliver signals.
559 560 561 |
# File 'lib/net-ssh-open3.rb', line 559 def open3_signal_open @open3_open_mutex.synchronize { @open3_open_semaphore.signal } end |
#open3_wait_open ⇒ Object
Suspend current thread execution until this channel is opened. Raises an exception if tracked during opening.
546 547 548 549 550 |
# File 'lib/net-ssh-open3.rb', line 546 def open3_wait_open @open3_open_mutex.synchronize { @open3_open_semaphore.wait(@open3_open_mutex) } raise *open3_exception if open3_exception self end |
#wait ⇒ Object
Wait for this channel to be closed.
553 554 555 556 |
# File 'lib/net-ssh-open3.rb', line 553 def wait @open3_waiter_thread.join self end |