mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-03 09:52:27 +00:00
fix: proper way to block tokio thread
This commit is contained in:
parent
fc573db375
commit
08be5e6592
3 changed files with 6 additions and 10 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -2514,12 +2514,6 @@ dependencies = [
|
|||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pollster"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2"
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic"
|
||||
version = "1.6.0"
|
||||
|
@ -3617,7 +3611,6 @@ dependencies = [
|
|||
"once_cell",
|
||||
"parking_lot",
|
||||
"paste",
|
||||
"pollster",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tinymist-query",
|
||||
|
|
|
@ -44,7 +44,6 @@ typst-ts-core = { version = "0.4.2-rc6", default-features = false, features = [
|
|||
"vector-bbox",
|
||||
"no-content-hint",
|
||||
] }
|
||||
pollster = "0.3.0"
|
||||
codespan-reporting = "0.11"
|
||||
typst-ts-compiler.workspace = true
|
||||
typst-preview.workspace = true
|
||||
|
|
|
@ -492,10 +492,14 @@ impl<Ctx> CompileClient<Ctx> {
|
|||
f: impl FnOnce(&mut Ctx) -> Ret + Send + 'static,
|
||||
) -> ZResult<Ret> {
|
||||
// get current async handle
|
||||
if tokio::runtime::Handle::try_current().is_ok() {
|
||||
if let Ok(e) = tokio::runtime::Handle::try_current() {
|
||||
let fut = self.steal_inner(f)?;
|
||||
// todo: remove blocking
|
||||
return pollster::block_on(fut).map_err(map_string_err("failed to steal"));
|
||||
return std::thread::spawn(move || {
|
||||
e.block_on(fut).map_err(map_string_err("failed to steal"))
|
||||
})
|
||||
.join()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
self.steal_inner(f)?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue