terminal/src/host/VtInputThread.hpp
Michael Niksa 56c35945b9
Rework locking and eventing during startup and shutdown to alleviate some VT issues (#2525)
Adjusts the startup and shutdown behavior of most threads in the console host to alleviate race conditions that are either exacerbated or introduced by the VT PTY threads.
2019-09-20 15:43:11 -07:00

52 lines
1.4 KiB
C++

/*++
Copyright (c) Microsoft Corporation
Licensed under the MIT license.
Module Name:
- VtInputThread.hpp
Abstract:
- Defines methods that wrap the thread that reads VT input from a pipe and
feeds it into the console's input buffer.
Author(s):
- Mike Griese (migrie) 15 Aug 2017
--*/
#pragma once
#include "..\terminal\parser\StateMachine.hpp"
#include "utf8ToWideCharParser.hpp"
namespace Microsoft::Console
{
class VtInputThread
{
public:
VtInputThread(wil::unique_hfile hPipe,
wil::shared_event shutdownEvent,
const bool inheritCursor);
~VtInputThread();
[[nodiscard]] HRESULT Start();
static DWORD WINAPI StaticVtInputThreadProc(_In_ LPVOID lpParameter);
[[nodiscard]] HRESULT DoReadInput();
private:
[[nodiscard]] HRESULT _HandleRunInput(_In_reads_(cch) const byte* const charBuffer, const int cch);
DWORD _InputThread();
[[nodiscard]] HRESULT _ReadInput();
wil::shared_event _shutdownEvent;
std::future<void> _shutdownWatchdog;
wil::unique_hfile _hFile;
wil::unique_handle _hThread;
DWORD _dwThreadId;
std::unique_ptr<Microsoft::Console::VirtualTerminal::StateMachine> _pInputStateMachine;
Utf8ToWideCharParser _utf8Parser;
};
}