Skip to content

Commit

Permalink
Merge pull request #81 from Anders429/features
Browse files Browse the repository at this point in the history
Rename `parallel` feature to `rayon`.
  • Loading branch information
Anders429 committed Aug 10, 2022
2 parents 9f87ea3 + 514d07d commit cb469af
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 46 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
rust:
- 1.58.0
- 1.60.0
- stable
- beta
- nightly
Expand All @@ -38,10 +38,11 @@ jobs:
strategy:
matrix:
rust:
- 1.58.0
- 1.60.0
- stable
- beta
- nightly
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
Expand All @@ -55,7 +56,7 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: hack
args: build --feature-powerset --optional-deps --exclude-features parallel --exclude-features rayon --target thumbv6m-none-eabi
args: build --feature-powerset --optional-deps --exclude-features rayon --target thumbv6m-none-eabi

fmt:
runs-on: ubuntu-latest
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "brood"
version = "0.1.0"
authors = ["Anders Evensen"]
edition = "2021"
rust-version = "1.58.0"
rust-version = "1.60.0"
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/Anders429/brood"
Expand All @@ -28,8 +28,8 @@ serde = {version = "1.0.133", default-features = false, features = ["alloc"], op
claim = "0.5.0"
rustversion = "1.0.6"
serde_test = "1.0.133"
trybuild = "1.0.61"
# Temporarily use this fork until https://github.com/dtolnay/trybuild/issues/171 is resolved.
trybuild = {git = "https://github.com/Anders429/trybuild"}

[features]
# TODO: Rename this to "rayon" when namespaced dependencies are stabilized in 1.60.0.
parallel = ["rayon", "hashbrown/rayon"]
rayon = ["dep:rayon", "hashbrown/rayon"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![codecov.io](https://img.shields.io/codecov/c/gh/Anders429/brood)](https://codecov.io/gh/Anders429/brood)
[![crates.io](https://img.shields.io/crates/v/brood)](https://crates.io/crates/brood)
[![docs.rs](https://docs.rs/brood/badge.svg)](https://docs.rs/brood)
[![MSRV](https://img.shields.io/badge/rustc-1.58.0+-yellow.svg)](#minimum-supported-rust-version)
[![MSRV](https://img.shields.io/badge/rustc-1.60.0+-yellow.svg)](#minimum-supported-rust-version)
[![License](https://img.shields.io/crates/l/brood)](#license)

A fast and flexible [entity component system](https://en.wikipedia.org/wiki/Entity_component_system) library.
Expand Down Expand Up @@ -281,7 +281,7 @@ world.run_schedule(&mut schedule);
Note that stages are determined by the `Views` of each `System`. `System`s whose `Views` do not contain conflicting mutable borrows of components are grouped together into a single stage.

## Minimum Supported Rust Version
This crate is guaranteed to compile on stable `rustc 1.58.0` and up.
This crate is guaranteed to compile on stable `rustc 1.60.0` and up.

## License
This project is licensed under either of
Expand Down
6 changes: 3 additions & 3 deletions src/archetype/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub(crate) use identifier::{Identifier, IdentifierRef};
#[cfg(feature = "serde")]
pub(crate) use impl_serde::{DeserializeColumn, SerializeColumn};

#[cfg(feature = "parallel")]
#[cfg(feature = "rayon")]
use crate::query::view::ParViews;
use crate::{
component::Component,
Expand Down Expand Up @@ -245,8 +245,8 @@ where

/// # Safety
/// Each component viewed by `V` must also be identified by this archetype's `Identifier`.
#[cfg(feature = "parallel")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "parallel")))]
#[cfg(feature = "rayon")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
pub(crate) unsafe fn par_view<'a, V>(&mut self) -> V::ParResults
where
V: ParViews<'a>,
Expand Down
4 changes: 2 additions & 2 deletions src/archetypes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ mod impl_eq;
#[cfg_attr(doc_cfg, doc(cfg(feature = "serde")))]
mod impl_serde;
mod iter;
#[cfg(feature = "parallel")]
#[cfg(feature = "rayon")]
mod par_iter;

#[cfg(feature = "serde")]
pub(crate) use impl_serde::DeserializeArchetypes;
pub(crate) use iter::IterMut;
#[cfg(feature = "parallel")]
#[cfg(feature = "rayon")]
pub(crate) use par_iter::ParIterMut;

use crate::{archetype, archetype::Archetype, entity, registry::Registry};
Expand Down
4 changes: 2 additions & 2 deletions src/archetypes/par_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::marker::PhantomData;
use hashbrown::raw::rayon::RawParIter;
use rayon::iter::{plumbing::UnindexedConsumer, ParallelIterator};

#[cfg_attr(doc_cfg, doc(cfg(feature = "parallel")))]
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
pub(crate) struct ParIterMut<'a, R>
where
R: Registry,
Expand Down Expand Up @@ -50,7 +50,7 @@ impl<R> Archetypes<R>
where
R: Registry,
{
#[cfg_attr(doc_cfg, doc(cfg(feature = "parallel")))]
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
pub(crate) fn par_iter_mut(&mut self) -> ParIterMut<R> {
ParIterMut::new(
// SAFETY: The `ParIterMut` containing this `RawIter` is guaranteed to not outlive
Expand Down
4 changes: 2 additions & 2 deletions src/query/result/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
//! [`World`]: crate::world::World

mod iter;
#[cfg(feature = "parallel")]
#[cfg(feature = "rayon")]
mod par_iter;

pub use iter::Iter;
#[cfg(feature = "parallel")]
#[cfg(feature = "rayon")]
pub use par_iter::ParIter;

use crate::{doc, hlist::define_null};
Expand Down
2 changes: 1 addition & 1 deletion src/query/result/par_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use rayon::iter::{
/// [`ParViews`]: crate::query::view::ParViews
/// [`result!`]: crate::query::result!
/// [`World`]: crate::world::World
#[cfg_attr(doc_cfg, doc(cfg(feature = "parallel")))]
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
pub struct ParIter<'a, R, F, V>
where
R: Registry,
Expand Down
4 changes: 2 additions & 2 deletions src/query/view/assertion_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl AssertionBuffer {
/// It is recommended to use [`with_capacity`] if possible, as it will save allocations.
///
/// [`with_capacity`]: AssertionBuffer::with_capacity()
#[cfg(feature = "parallel")]
#[cfg(feature = "rayon")]
pub(crate) fn new() -> Self {
Self::with_capacity(0)
}
Expand Down Expand Up @@ -118,7 +118,7 @@ mod tests {
struct A;
struct B;

#[cfg(feature = "parallel")]
#[cfg(feature = "rayon")]
#[test]
fn new() {
let buffer = AssertionBuffer::new();
Expand Down
4 changes: 2 additions & 2 deletions src/query/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@
//! [`World`]: crate::world::World.

mod assertion_buffer;
#[cfg(feature = "parallel")]
#[cfg(feature = "rayon")]
mod par;

pub(crate) mod seal;

#[cfg(feature = "parallel")]
#[cfg(feature = "rayon")]
pub use par::{ParView, ParViews};

pub(crate) use assertion_buffer::AssertionBuffer;
Expand Down
4 changes: 2 additions & 2 deletions src/query/view/par/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use seal::{ParViewSeal, ParViewsSeal};
/// [`ParSystem`]: crate::system::ParSystem
/// [`par_query`]: crate::world::World::par_query()
/// [`View`]: crate::query::view::View
#[cfg_attr(doc_cfg, doc(cfg(feature = "parallel")))]
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
pub trait ParView<'a>: Filter + ParViewSeal<'a> {}

impl<'a, C> ParView<'a> for &C where C: Component + Sync {}
Expand Down Expand Up @@ -74,7 +74,7 @@ impl<'a> ParView<'a> for entity::Identifier {}
/// [`ParView`]: crate::query::view::ParView
/// [`par_query`]: crate::world::World::par_query()
/// [`Views`]: crate::query::view::Views
#[cfg_attr(doc_cfg, doc(cfg(feature = "parallel")))]
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
pub trait ParViews<'a>: Filter + ParViewsSeal<'a> {}

impl<'a> ParViews<'a> for Null {}
Expand Down
10 changes: 5 additions & 5 deletions src/system/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@
//! [`System`]: crate::system::System
//! [`World`]: crate::world::World

#[cfg(feature = "parallel")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "parallel")))]
#[cfg(feature = "rayon")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
pub mod schedule;

mod null;
#[cfg(feature = "parallel")]
#[cfg(feature = "rayon")]
mod par;

pub use null::Null;
#[cfg(feature = "parallel")]
#[cfg(feature = "rayon")]
pub use par::ParSystem;
#[cfg(feature = "parallel")]
#[cfg(feature = "rayon")]
#[doc(inline)]
pub use schedule::Schedule;

Expand Down
4 changes: 2 additions & 2 deletions src/system/null.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(feature = "parallel")]
#[cfg(feature = "rayon")]
use crate::system::ParSystem;
use crate::{
query::{filter, result, view},
Expand Down Expand Up @@ -38,7 +38,7 @@ impl<'a> System<'a> for Null {
}
}

#[cfg(feature = "parallel")]
#[cfg(feature = "rayon")]
impl<'a> ParSystem<'a> for Null {
type Filter = filter::None;
type Views = view::Null;
Expand Down
2 changes: 1 addition & 1 deletion src/system/par.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use crate::{
/// [`run`]: crate::system::ParSystem::run()
/// [`System`]: crate::system::System
/// [`World`]: crate::world::World
#[cfg_attr(doc_cfg, doc(cfg(feature = "parallel")))]
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
pub trait ParSystem<'a> {
type Filter: Filter;
type Views: ParViews<'a>;
Expand Down
2 changes: 1 addition & 1 deletion src/system/schedule/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ use stage::Stages;
/// [`schedule::Builder`]: crate::system::schedule::Builder
/// [`Stages`]: crate::system::schedule::stage::Stages
/// [`System`]: crate::system::System
#[cfg_attr(doc_cfg, doc(cfg(feature = "parallel")))]
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
pub struct Schedule<S> {
stages: S,
}
Expand Down
22 changes: 11 additions & 11 deletions src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::{
registry::Registry,
system::System,
};
#[cfg(feature = "parallel")]
#[cfg(feature = "rayon")]
use crate::{
query::view::ParViews,
system::{schedule::stage::Stages, ParSystem, Schedule},
Expand Down Expand Up @@ -318,8 +318,8 @@ where
/// [`ParViews`]: crate::query::view::ParViews
/// [`query`]: crate::query
/// [`query()`]: World::query()
#[cfg(feature = "parallel")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "parallel")))]
#[cfg(feature = "rayon")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
pub fn par_query<'a, V, F>(&'a mut self) -> result::ParIter<'a, R, F, V>
where
V: ParViews<'a>,
Expand All @@ -336,8 +336,8 @@ where
/// # Safety
/// The [`Views`] `V` must follow Rust's borrowing rules, meaning that a component that is
/// mutably borrowed is only borrowed once.
#[cfg(feature = "parallel")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "parallel")))]
#[cfg(feature = "rayon")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
pub(crate) unsafe fn query_unchecked<'a, V, F>(&'a mut self) -> result::Iter<'a, R, F, V>
where
V: Views<'a>,
Expand All @@ -351,8 +351,8 @@ where
/// # Safety
/// The [`ParViews`] `V` must follow Rust's borrowing rules, meaning that a component that is
/// mutably borrowed is only borrowed once.
#[cfg(feature = "parallel")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "parallel")))]
#[cfg(feature = "rayon")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
pub(crate) unsafe fn par_query_unchecked<'a, V, F>(&'a mut self) -> result::ParIter<'a, R, F, V>
where
V: ParViews<'a>,
Expand Down Expand Up @@ -454,8 +454,8 @@ where
/// ```
///
/// [`ParSystem`]: crate::system::ParSystem
#[cfg(feature = "parallel")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "parallel")))]
#[cfg(feature = "rayon")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
pub fn run_par_system<'a, S>(&'a mut self, par_system: &mut S)
where
S: ParSystem<'a>,
Expand Down Expand Up @@ -524,8 +524,8 @@ where
/// ```
///
/// [`Schedule`]: crate::system::Schedule
#[cfg(feature = "parallel")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "parallel")))]
#[cfg(feature = "rayon")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
pub fn run_schedule<'a, S>(&'a mut self, schedule: &mut Schedule<S>)
where
S: Stages<'a>,
Expand Down
2 changes: 1 addition & 1 deletion tests/trybuild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ trybuild_test!(entities);
trybuild_test!(entity);
trybuild_test!(registry);
trybuild_test!(result);
#[cfg(feature = "parallel")]
#[cfg(feature = "rayon")]
trybuild_test!(stages);
trybuild_test!(views);

0 comments on commit cb469af

Please sign in to comment.