mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-12-21 19:01:25 +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: std::future::Future + 'static,
|
||||||
F::Output: 'static,
|
F::Output: 'static,
|
||||||
{
|
{
|
||||||
|
#[cfg(not(tokio_unstable))]
|
||||||
|
let _ = name;
|
||||||
|
|
||||||
let span = tracing::trace_span!(parent: None, "spawn task");
|
let span = tracing::trace_span!(parent: None, "spawn task");
|
||||||
let guard = span.enter();
|
let guard = span.enter();
|
||||||
|
|
||||||
|
#[cfg(tokio_unstable)]
|
||||||
let handle = tokio::task::Builder::new()
|
let handle = tokio::task::Builder::new()
|
||||||
.name(name)
|
.name(name)
|
||||||
.spawn_local(future)
|
.spawn_local(future)
|
||||||
.expect("Failed to spawn");
|
.expect("Failed to spawn");
|
||||||
|
#[cfg(not(tokio_unstable))]
|
||||||
|
let handle = tokio::task::spawn_local(future);
|
||||||
|
|
||||||
drop(guard);
|
drop(guard);
|
||||||
handle
|
handle
|
||||||
|
@ -64,15 +70,21 @@ where
|
||||||
F: FnOnce() -> Out + Send + 'static,
|
F: FnOnce() -> Out + Send + 'static,
|
||||||
Out: Send + 'static,
|
Out: Send + 'static,
|
||||||
{
|
{
|
||||||
|
#[cfg(not(tokio_unstable))]
|
||||||
|
let _ = name;
|
||||||
|
|
||||||
let outer_span = tracing::Span::current();
|
let outer_span = tracing::Span::current();
|
||||||
|
|
||||||
let span = tracing::trace_span!(parent: None, "spawn blocking task");
|
let span = tracing::trace_span!(parent: None, "spawn blocking task");
|
||||||
let guard = span.enter();
|
let guard = span.enter();
|
||||||
|
|
||||||
|
#[cfg(tokio_unstable)]
|
||||||
let handle = tokio::task::Builder::new()
|
let handle = tokio::task::Builder::new()
|
||||||
.name(name)
|
.name(name)
|
||||||
.spawn_blocking(move || outer_span.in_scope(function))
|
.spawn_blocking(move || outer_span.in_scope(function))
|
||||||
.expect("Failed to spawn");
|
.expect("Failed to spawn");
|
||||||
|
#[cfg(not(tokio_unstable))]
|
||||||
|
let handle = tokio::task::spawn_blocking(move || outer_span.in_scope(function));
|
||||||
|
|
||||||
drop(guard);
|
drop(guard);
|
||||||
handle
|
handle
|
||||||
|
|
Loading…
Reference in a new issue