fix: tokio tasks
This commit is contained in:
@@ -3,7 +3,7 @@ use super::{
|
||||
scenegraph::Scenegraph,
|
||||
};
|
||||
use crate::{
|
||||
core::{registry::OwnedRegistry, task},
|
||||
core::registry::OwnedRegistry,
|
||||
nodes::{
|
||||
Node, audio, drawable, fields, input, items,
|
||||
root::{ClientState, Root},
|
||||
@@ -143,14 +143,11 @@ impl Client {
|
||||
})
|
||||
.unwrap_or_else(|| "??".to_string());
|
||||
let _ = client.dispatch_join_handle.get_or_init(|| {
|
||||
task::new(
|
||||
|| {
|
||||
format!(
|
||||
"client dispatch pid={} exe={}",
|
||||
&pid_printable, &exe_printable,
|
||||
)
|
||||
},
|
||||
{
|
||||
tokio::task::Builder::new()
|
||||
.name(&format!(
|
||||
"Stardust client \"{exe_printable}\" dispatch, pid={pid_printable}",
|
||||
))
|
||||
.spawn({
|
||||
let client = client.clone();
|
||||
async move {
|
||||
loop {
|
||||
@@ -160,14 +157,15 @@ impl Client {
|
||||
let _ = message_time_tx.send(Instant::now());
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
.unwrap()
|
||||
})
|
||||
.unwrap()
|
||||
});
|
||||
let _ = client.flush_join_handle.get_or_init(|| {
|
||||
task::new(
|
||||
|| format!("client flush pid={} exe={}", &pid_printable, &exe_printable,),
|
||||
{
|
||||
tokio::task::Builder::new()
|
||||
.name(&format!(
|
||||
"Stardust client \"{exe_printable}\" flush, pid={pid_printable}",
|
||||
))
|
||||
.spawn({
|
||||
let client = client.clone();
|
||||
async move {
|
||||
loop {
|
||||
@@ -176,9 +174,8 @@ impl Client {
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
.unwrap()
|
||||
})
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
Ok(client)
|
||||
|
||||
@@ -8,4 +8,3 @@ pub mod error;
|
||||
pub mod registry;
|
||||
pub mod resource;
|
||||
pub mod scenegraph;
|
||||
pub mod task;
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
use color_eyre::eyre::Result;
|
||||
use std::future::Future;
|
||||
use tokio::task::JoinHandle;
|
||||
|
||||
#[allow(unused_variables)]
|
||||
pub fn new<
|
||||
F: FnOnce() -> S,
|
||||
S: AsRef<str>,
|
||||
A: Future<Output = O> + Send + 'static,
|
||||
O: Send + 'static,
|
||||
>(
|
||||
name_fn: F,
|
||||
async_future: A,
|
||||
) -> Result<JoinHandle<O>> {
|
||||
#[cfg(not(feature = "profile_tokio"))]
|
||||
let result = Ok(tokio::task::spawn(async_future));
|
||||
#[cfg(feature = "profile_tokio")]
|
||||
let result = tokio::task::Builder::new()
|
||||
.name(name_fn().as_ref())
|
||||
.spawn(async_future)
|
||||
.map_err(Into::into);
|
||||
result
|
||||
}
|
||||
Reference in New Issue
Block a user