summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWez Furlong <wez@wezfurlong.org>2020-01-22 18:51:08 -0800
committerWez Furlong <wez@wezfurlong.org>2020-01-22 18:51:08 -0800
commit550eb1ec0ba6c6d88e44d5caeaea73fc5bf594ed (patch)
tree492085089c99fa61401196897ef3784fa98ea806
parent2aac7ab959ca9856108acc2e46c6c75a017ef41b (diff)
downloadssh2-rs-550eb1ec0ba6c6d88e44d5caeaea73fc5bf594ed.zip
add note about Session, Send, Sync, Clone and concurrency
-rw-r--r--src/session.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/session.rs b/src/session.rs
index 442deaa..c7f32cf 100644
--- a/src/session.rs
+++ b/src/session.rs
@@ -78,6 +78,20 @@ unsafe impl Send for SessionInner {}
/// All other structures are based on an SSH session and cannot outlive a
/// session. Sessions are created and then have the TCP socket handed to them
/// (via the `set_tcp_stream` method).
+///
+/// `Session`, and any objects its methods return, hold a reference to the underlying
+/// SSH session. You may clone `Session` to obtain another handle referencing
+/// the same session, and create multiple `Channel` and `Stream` objects
+/// from that same underlying session, which can all be passed across thread
+/// boundaries (they are `Send` and `Sync`). These are all related objects and
+/// are internally synchronized via a `Mutex` to make it safe to pass them
+/// around in this way.
+///
+/// This means that a blocking read from a `Channel` or `Stream` will block
+/// all other calls on objects created from the same underlying `Session`.
+/// If you need the ability to perform concurrent operations then you will
+/// need to create separate `Session` instances, or employ non-blocking mode,
+/// perhaps using the `async-ssh2` crate.
#[derive(Clone)]
pub struct Session {
inner: Arc<Mutex<SessionInner>>,