Skip to content

Commit

Permalink
Impl Send + Sync for UnsafeWorldCell (#30)
Browse files Browse the repository at this point in the history
This makes `Fetcher` implement `Send + Sync` as well.
  • Loading branch information
rj00a authored Mar 24, 2024
1 parent a629e4c commit 0913f3b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 0.4.1 - 2024-03-24

- Impl `Send` and `Sync` for `UnsafeWorldCell` and `Fetcher`.
- Removed dependency on `memoffset`.

## 0.4.0 - 2024-03-09

- Renamed "system" to "handler" to avoid confusion with other ECS libraries.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rayon = ["dep:rayon"]
[dependencies]
ahash = { version = "0.8.7", default-features = false }
bumpalo = "3.14.0"
evenio_macros = { path = "evenio_macros", version = "0.4.0" }
evenio_macros = { path = "evenio_macros", version = "0.4.1" }
hashbrown = { version = "0.14.3", default-features = false, features = [
"inline-more",
] }
Expand Down Expand Up @@ -61,7 +61,7 @@ harness = false

[workspace.package]
edition = "2021"
version = "0.4.0"
version = "0.4.1"
license = "MIT"
repository = "https://github.com/rj00a/evenio"

Expand Down
6 changes: 6 additions & 0 deletions src/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -960,4 +960,10 @@ mod tests {

world.send(E1);
}

fn _assert_auto_trait_impls<Q>()
where
for<'a> Fetcher<'a, Q>: Send + Sync,
{
}
}
7 changes: 7 additions & 0 deletions src/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,11 @@ impl<'a> UnsafeWorldCell<'a> {
}
}

// SAFETY: `&World` and `&mut World` are `Send`.
unsafe impl Send for UnsafeWorldCell<'_> {}
// SAFETY: `&World` and `&mut World` are `Sync`.
unsafe impl Sync for UnsafeWorldCell<'_> {}

#[cfg(test)]
mod tests {
use alloc::sync::Arc;
Expand Down Expand Up @@ -1222,6 +1227,8 @@ mod tests {
fn _assert_auto_trait_impls()
where
World: Send + Sync + UnwindSafe + RefUnwindSafe,
for<'a> &'a World: Send + Sync,
for<'a> &'a mut World: Send + Sync,
{
}
}

0 comments on commit 0913f3b

Please sign in to comment.