mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-12-22 03:11:24 +00:00
Enable building without tokio_unstable
This commit is contained in:
parent
722a02e679
commit
3ef4097ceb
3 changed files with 14 additions and 2 deletions
|
@ -1,2 +0,0 @@
|
|||
[build]
|
||||
rustflags = ["--cfg", "tokio_unstable", "--cfg", "uuid_unstable"]
|
2
.cargo/config.toml
Normal file
2
.cargo/config.toml
Normal file
|
@ -0,0 +1,2 @@
|
|||
[build]
|
||||
rustflags = ["--cfg", "tokio_unstable"]
|
12
src/sync.rs
12
src/sync.rs
|
@ -46,13 +46,19 @@ where
|
|||
F: std::future::Future + 'static,
|
||||
F::Output: 'static,
|
||||
{
|
||||
#[cfg(not(tokio_unstable))]
|
||||
let _ = name;
|
||||
|
||||
let span = tracing::trace_span!(parent: None, "spawn task");
|
||||
let guard = span.enter();
|
||||
|
||||
#[cfg(tokio_unstable)]
|
||||
let handle = tokio::task::Builder::new()
|
||||
.name(name)
|
||||
.spawn_local(future)
|
||||
.expect("Failed to spawn");
|
||||
#[cfg(not(tokio_unstable))]
|
||||
let handle = tokio::task::spawn_local(future);
|
||||
|
||||
drop(guard);
|
||||
handle
|
||||
|
@ -64,15 +70,21 @@ where
|
|||
F: FnOnce() -> Out + Send + 'static,
|
||||
Out: Send + 'static,
|
||||
{
|
||||
#[cfg(not(tokio_unstable))]
|
||||
let _ = name;
|
||||
|
||||
let outer_span = tracing::Span::current();
|
||||
|
||||
let span = tracing::trace_span!(parent: None, "spawn blocking task");
|
||||
let guard = span.enter();
|
||||
|
||||
#[cfg(tokio_unstable)]
|
||||
let handle = tokio::task::Builder::new()
|
||||
.name(name)
|
||||
.spawn_blocking(move || outer_span.in_scope(function))
|
||||
.expect("Failed to spawn");
|
||||
#[cfg(not(tokio_unstable))]
|
||||
let handle = tokio::task::spawn_blocking(move || outer_span.in_scope(function));
|
||||
|
||||
drop(guard);
|
||||
handle
|
||||
|
|
Loading…
Reference in a new issue