Fix constant thread creation on Windows (#36779)
See https://github.com/zed-industries/zed/issues/36057#issuecomment-3215808649 Fixes https://github.com/zed-industries/zed/issues/36057 Release Notes: - N/A
This commit is contained in:
parent
949398cb93
commit
4605b96630
1 changed files with 3 additions and 15 deletions
|
@ -9,10 +9,8 @@ use parking::Parker;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use windows::{
|
use windows::{
|
||||||
Foundation::TimeSpan,
|
|
||||||
System::Threading::{
|
System::Threading::{
|
||||||
ThreadPool, ThreadPoolTimer, TimerElapsedHandler, WorkItemHandler, WorkItemOptions,
|
ThreadPool, ThreadPoolTimer, TimerElapsedHandler, WorkItemHandler, WorkItemPriority,
|
||||||
WorkItemPriority,
|
|
||||||
},
|
},
|
||||||
Win32::{
|
Win32::{
|
||||||
Foundation::{LPARAM, WPARAM},
|
Foundation::{LPARAM, WPARAM},
|
||||||
|
@ -56,12 +54,7 @@ impl WindowsDispatcher {
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
ThreadPool::RunWithPriorityAndOptionsAsync(
|
ThreadPool::RunWithPriorityAsync(&handler, WorkItemPriority::High).log_err();
|
||||||
&handler,
|
|
||||||
WorkItemPriority::High,
|
|
||||||
WorkItemOptions::TimeSliced,
|
|
||||||
)
|
|
||||||
.log_err();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dispatch_on_threadpool_after(&self, runnable: Runnable, duration: Duration) {
|
fn dispatch_on_threadpool_after(&self, runnable: Runnable, duration: Duration) {
|
||||||
|
@ -72,12 +65,7 @@ impl WindowsDispatcher {
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
let delay = TimeSpan {
|
ThreadPoolTimer::CreateTimer(&handler, duration.into()).log_err();
|
||||||
// A time period expressed in 100-nanosecond units.
|
|
||||||
// 10,000,000 ticks per second
|
|
||||||
Duration: (duration.as_nanos() / 100) as i64,
|
|
||||||
};
|
|
||||||
ThreadPoolTimer::CreateTimer(&handler, delay).log_err();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue