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.
529 530 531 532 533 534 535 |
# File 'lib/net-ssh-open3.rb', line 529 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.
519 520 521 |
# File 'lib/net-ssh-open3.rb', line 519 def open3_close_semaphore @open3_close_semaphore end |
#open3_exception ⇒ Object (readonly)
An exception tracked during channel opening, if any.
522 523 524 |
# File 'lib/net-ssh-open3.rb', line 522 def open3_exception @open3_exception end |
#open3_waiter_thread ⇒ Object
Waiter thread that watches this channel.
525 526 527 |
# File 'lib/net-ssh-open3.rb', line 525 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.
539 540 541 542 543 544 545 |
# File 'lib/net-ssh-open3.rb', line 539 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.
549 550 551 552 553 554 |
# File 'lib/net-ssh-open3.rb', line 549 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.
558 559 560 561 562 563 564 565 |
# File 'lib/net-ssh-open3.rb', line 558 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.
593 594 595 |
# File 'lib/net-ssh-open3.rb', line 593 def open3_signal_close @open3_close_semaphore.signal end |
#open3_signal_open ⇒ Object
Flag this channel as opened and deliver signals.
587 588 589 |
# File 'lib/net-ssh-open3.rb', line 587 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.
574 575 576 577 578 |
# File 'lib/net-ssh-open3.rb', line 574 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.
581 582 583 584 |
# File 'lib/net-ssh-open3.rb', line 581 def wait @open3_waiter_thread.join self end |