Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (3)
Tags (3)
master
zadjii-msft-patch-readme
richturn/retarget-echocon
1904.29002
1810.02002
1708.14008
master
Branches (3)
Tags (3)
master
zadjii-msft-patch-readme
richturn/retarget-echocon
1904.29002
1810.02002
1708.14008
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (3)
Tags (3)
master
zadjii-msft-patch-readme
richturn/retarget-echocon
1904.29002
1810.02002
1708.14008
Terminal
/
src
/
server
/
WaitQueue.cpp
Terminal
/
src
/
server
/
WaitQueue.cpp
WaitQueue.cpp 4.61 KB
Copy Edit Raw Blame History
Dustin Howett authored 2019年05月03日 06:29 +08:00 . Initial release of the Windows Terminal source code
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include "precomp.h"
#include "WaitQueue.h"
#include "WaitBlock.h"
#include "..\host\globals.h"
#include "..\host\utils.hpp"
// Routine Description:
// - Instantiates a new ConsoleWaitQueue
ConsoleWaitQueue::ConsoleWaitQueue() :
_blocks()
{
}
// Routine Description:
// - Destructs a ConsoleWaitQueue
// - This will notify any remaining waiting items that the associated process/object is dying.
ConsoleWaitQueue::~ConsoleWaitQueue()
{
// Notify all blocks that the thread or object is dying when destroyed.
NotifyWaiters(TRUE, WaitTerminationReason::ThreadDying);
}
// Routine Description:
// - Establishes a wait (call me back later) for a particular message with a given callback routine and its parameter
// Arguments:
// - pWaitReplyMessage - The API message that we're deferring until data is available later.
// - pWaiter - The context/callback information to restore and dispatch the call later.
// Return Value:
// - S_OK if enqueued appropriately and everything is alright. Or suitable HRESULT failure otherwise.
[[nodiscard]]
HRESULT ConsoleWaitQueue::s_CreateWait(_Inout_ CONSOLE_API_MSG* const pWaitReplyMessage,
_In_ IWaitRoutine* const pWaiter)
{
// Normally we'd have the Wait Queue handle the insertion of the block into the queue, but
// the console does queues in a somewhat special way.
//
// Each block belongs in two queues:
// 1. The process queue of the client that dispatched the request
// 2. The object queue that the request will be serviced by
// As such, when a wait occurs, it gets added to both queues.
//
// It will end up being serviced by one or the other queue, but when it is serviced, it must be
// removed from both so it is not double processed.
//
// Therefore, I've inverted the queue management responsibility into the WaitBlock itself
// and made it a friend to this WaitQueue class.
return ConsoleWaitBlock::s_CreateWait(pWaitReplyMessage,
pWaiter);
}
// Routine Description:
// - Instructs this queue to attempt to callback waiting requests
// Arguments:
// - fNotifyAll - If true, we will notify all items in the queue. If false, we will only notify the first item.
// Return Value:
// - True if any block was successfully notified. False if no blocks were successful.
bool ConsoleWaitQueue::NotifyWaiters(const bool fNotifyAll)
{
return NotifyWaiters(fNotifyAll, WaitTerminationReason::NoReason);
}
// Routine Description:
// - Instructs this queue to attempt to callback waiting requests and request termination with the given reason
// Arguments:
// - fNotifyAll - If true, we will notify all items in the queue. If false, we will only notify the first item.
// - TerminationReason - A reason/message to pass to each waiter signaling it should terminate appropriately.
// Return Value:
// - True if any block was successfully notified. False if no blocks were successful.
bool ConsoleWaitQueue::NotifyWaiters(const bool fNotifyAll,
const WaitTerminationReason TerminationReason)
{
bool fResult = false;
auto it = _blocks.cbegin();
while (!_blocks.empty() && it != _blocks.cend())
{
ConsoleWaitBlock* const WaitBlock = (*it);
if (nullptr == WaitBlock)
{
break;
}
auto const nextIt = std::next(it); // we have to capture next before it is potentially erased
if (_NotifyBlock(WaitBlock, TerminationReason))
{
fResult = true;
}
if (!fNotifyAll)
{
break;
}
it = nextIt;
}
return fResult;
}
// Routine Description:
// - A helper to delete successfully notified callbacks
// Arguments:
// - pWaitBlock - A block containing callback data
// - TerminationReason - Optional reason to tell the callback to terminate. If 0, we're not requesting termination.
// Return Value:
// - True if callback successfully delivered data. False if callback still needs to wait longer.
bool ConsoleWaitQueue::_NotifyBlock(_In_ ConsoleWaitBlock* pWaitBlock,
_In_ WaitTerminationReason TerminationReason)
{
// Attempt to notify block with the given reason.
bool const fResult = pWaitBlock->Notify(TerminationReason);
if (fResult)
{
// If it was successful, delete it. (It will remove itself from appropriate queues.)
delete pWaitBlock;
}
return fResult;
}
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

The new Windows Terminal, and the original Windows console host -- all in the same place!
Cancel

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/AbstractFactory/Terminal.git
git@gitee.com:AbstractFactory/Terminal.git
AbstractFactory
Terminal
Terminal
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /