-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement ConnectionState and closeOnExit=graceful/always/never #3623
Conversation
commit c36b2482c04070529cbb009b09ec60cea70da8bd Merge: 4d6e975 c274b38 Author: Dustin Howett <[email protected]> Date: Fri Nov 8 14:16:44 2019 -0800 Merge remote-tracking branch 'github/master' into dev/duhowett/closeonexit commit 4d6e975 Author: Dustin Howett <[email protected]> Date: Wed Nov 6 15:49:38 2019 -0800 further hax commit 1950413 Author: Dustin Howett <[email protected]> Date: Wed Nov 6 07:30:32 2019 -0800 hacks: try to implement the state thing commit 22dd029 Merge: 5763be3 357e835 Author: Dustin Howett <[email protected]> Date: Wed Nov 6 15:15:21 2019 -0800 Merge remote-tracking branch 'github/master' into HEAD commit 5763be3 Author: Dustin Howett <[email protected]> Date: Tue Nov 5 17:47:22 2019 -0800 Spec: propose an evolution of closeOnExit and TerminalConnection
f8fae5a
to
17f1025
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm 27/32, and it's 5pm here, so unfortunately this is going to have to wait till monday from me :(
Nothing major so far though
std::lock_guard<std::mutex> stateLock{ _stateMutex }; | ||
// dark magic: this is a C++17 fold expression that expands into | ||
// state == 1 || state == 2 || state == 3 ... | ||
return (... || (_connectionState == args)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't understand what this dark magic does. is it equivalent to the following:
_connectionState == args[0] || _connectionState == args[1] || _connectionState == args[2] ...
(if you could index into the params like that?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YES! Exactly.
And the one above it is like
typeof(args[0]) == ConnectionState && typeof(args[1] == ConnectionState) && ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to expand these since i have to make a comment revision anyway
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose none of my comments are more than nits.
{ | ||
_state = State::NoConnect; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just remove the AzureState::NoConnect
state entirely now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm working on the AZ conn in my free time, I'll defer this to then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
er defer this to that work
@@ -156,8 +156,11 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation | |||
// DON'T CALL _InitializeTerminal here - wait until the swap chain is loaded to do that. | |||
|
|||
// Subscribe to the connection's disconnected event and call our connection closed handlers. | |||
_connection.TerminalDisconnected([=]() { | |||
_connectionClosedHandlers(); | |||
_connectionStateChangedRevoker = _connection.StateChanged(winrt::auto_revoke, [weakThis = get_weak()](auto&& /*s*/, auto&& /*v*/) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a pattern we should probably be using in other places, right? Where the event handler doesn't capture a strong ref to the handler object? (maybe we should file a CodeHealth task for this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, absolutely.
🎉 Handy links: |
I curiously tried the new
When opening a new tab with Build Script, the script |
if I recall correctly, You want |
You are absolutely right, thank you! |
Summary of the Pull Request
This pull request implements the new
ITerminalConnection::ConnectionState
interface (enum, event) and connects it through TerminalControl to Pane, Tab and App as specified in #2039. It does so to implementcloseOnExit
=graceful
in addition to the other two normal CoE types.It also:
CascadiaSettings
through a function that looks it up by using the current Xaml application'sAppLogic
.:crazy_eyes:
AzureConnection
. This required moving the Azure connection's state machine to use another enum name (oops).WINRT_CALLBACK
, a oneshot callback likeTYPED_EVENT
._connecting
and_closing
members with just one uberstate.References
Specification is in PR #2039.
PR Checklist