# Objective - Fixes #10664 ## Solution - `pub use futures_lite as future` :) --- ## Changelog - Made `futures_lite` available as `future` in the `bevy_tasks` module. ## Migration Guide - Remove `futures_lite` from `Cargo.toml`. ```diff [dependencies] bevy = "0.12.0" - futures-lite = "1.4.0" ``` - Replace `futures_lite` imports with `bevy::tasks::future`. ```diff - use futures_lite::poll_once; + use bevy::tasks::future::poll_once; ```
64 lines
1.9 KiB
Rust
64 lines
1.9 KiB
Rust
#![warn(missing_docs)]
|
|
#![doc = include_str!("../README.md")]
|
|
|
|
mod slice;
|
|
pub use slice::{ParallelSlice, ParallelSliceMut};
|
|
|
|
mod task;
|
|
pub use task::Task;
|
|
|
|
#[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))]
|
|
mod task_pool;
|
|
#[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))]
|
|
pub use task_pool::{Scope, TaskPool, TaskPoolBuilder};
|
|
|
|
#[cfg(any(target_arch = "wasm32", not(feature = "multi-threaded")))]
|
|
mod single_threaded_task_pool;
|
|
#[cfg(any(target_arch = "wasm32", not(feature = "multi-threaded")))]
|
|
pub use single_threaded_task_pool::{FakeTask, Scope, TaskPool, TaskPoolBuilder, ThreadExecutor};
|
|
|
|
mod usages;
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
pub use usages::tick_global_task_pools_on_main_thread;
|
|
pub use usages::{AsyncComputeTaskPool, ComputeTaskPool, IoTaskPool};
|
|
|
|
#[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))]
|
|
mod thread_executor;
|
|
#[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))]
|
|
pub use thread_executor::{ThreadExecutor, ThreadExecutorTicker};
|
|
|
|
#[cfg(feature = "async-io")]
|
|
pub use async_io::block_on;
|
|
#[cfg(not(feature = "async-io"))]
|
|
pub use futures_lite::future::block_on;
|
|
|
|
mod iter;
|
|
pub use iter::ParallelIterator;
|
|
|
|
pub use futures_lite;
|
|
|
|
#[allow(missing_docs)]
|
|
pub mod prelude {
|
|
#[doc(hidden)]
|
|
pub use crate::{
|
|
block_on,
|
|
iter::ParallelIterator,
|
|
slice::{ParallelSlice, ParallelSliceMut},
|
|
usages::{AsyncComputeTaskPool, ComputeTaskPool, IoTaskPool},
|
|
};
|
|
}
|
|
|
|
use std::num::NonZeroUsize;
|
|
|
|
/// Gets the logical CPU core count available to the current process.
|
|
///
|
|
/// This is identical to [`std::thread::available_parallelism`], except
|
|
/// it will return a default value of 1 if it internally errors out.
|
|
///
|
|
/// This will always return at least 1.
|
|
pub fn available_parallelism() -> usize {
|
|
std::thread::available_parallelism()
|
|
.map(NonZeroUsize::get)
|
|
.unwrap_or(1)
|
|
}
|