mirror of
https://github.com/denoland/deno.git
synced 2025-08-31 07:47:46 +00:00
fix(lsp): preserve notification order after init flag is raised (#28733)
This commit is contained in:
parent
ec05282346
commit
7509fc26dd
1 changed files with 15 additions and 7 deletions
|
@ -1,20 +1,28 @@
|
|||
// Copyright 2018-2025 the Deno authors. MIT license.
|
||||
|
||||
use tokio_util::sync::CancellationToken;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct AsyncFlag(CancellationToken);
|
||||
use tokio::sync::Semaphore;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AsyncFlag(Arc<Semaphore>);
|
||||
|
||||
impl Default for AsyncFlag {
|
||||
fn default() -> Self {
|
||||
Self(Arc::new(Semaphore::new(0)))
|
||||
}
|
||||
}
|
||||
|
||||
impl AsyncFlag {
|
||||
pub fn raise(&self) {
|
||||
self.0.cancel();
|
||||
self.0.close();
|
||||
}
|
||||
|
||||
pub fn is_raised(&self) -> bool {
|
||||
self.0.is_cancelled()
|
||||
self.0.is_closed()
|
||||
}
|
||||
|
||||
pub fn wait_raised(&self) -> impl std::future::Future<Output = ()> + '_ {
|
||||
self.0.cancelled()
|
||||
pub async fn wait_raised(&self) {
|
||||
self.0.acquire().await.unwrap_err();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue