-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Command and RemoteChild owning their session
Supporting session-owning commands (and children) makes it easier to e.g. move long-running children around, or store them around in structures, without having to deal with self-reference issues. Currently, support is limited to clonable smart pointers which can be coerced to `&Session`. After some testing / discussion, `Deref` seems like a better bound than `AsRef` as it works with references, and thus (amongst other things) allows the existing `Session::command` and `Session::raw_command` to go through the new associated function. Provide an `arc_[raw_]command` helper as wrapping an `Arc<Session>` to unbound the command (and child) from the session's scope is the primary and likely major use case of this feature. Does not work with a bare `Session` because `Command::spawn`, `Command::output`, and `Command::status` take self by (mutable) reference, so there is no way to consume the `Session` out. Generally `Command` as a builder is set up around chaining mutable references rather than moving ownership. Had to shuffle names a bit to try and avoid breaking backwards compatibility, which is not great: the internal `Command` becomes the external `OwningCommand`, and the old `RemoteChild` is now `Child`, with the external `RemoteChild` being an alias. Also add an owning version of `Session::subsystem` as well, following the same pattern, since while `subsystem` creates a `OwningCommand` it goes through a different path and thus can't be handled by `Session::to_command`.
- Loading branch information
Showing
6 changed files
with
282 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.