From 5e6800d2b7d32bfb914bbbefaf32f52b003d1c9f Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Fri, 22 Dec 2023 05:19:26 +0000 Subject: [PATCH 1/3] Explain EventWriter limits concurrency --- crates/bevy_ecs/src/event.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/event.rs b/crates/bevy_ecs/src/event.rs index 7e2284dd4850a..159611a8eff75 100644 --- a/crates/bevy_ecs/src/event.rs +++ b/crates/bevy_ecs/src/event.rs @@ -484,7 +484,15 @@ impl<'w, 's, E: Event> EventReader<'w, 's, E> { /// # bevy_ecs::system::assert_is_system(my_system); /// ``` /// -/// # Limitations +/// # Concurrently +/// +/// `EventWriter` param has [`ResMut>`](Events) inside. So two systems declaring `EventWriter` params +/// for the same `` won't be executed concurrently. +/// +/// This does not apply to [`EventReader`](EventReader) though: reader systems are executed concurrently +/// (but not with `EventWriter` systems). +/// +/// # Untyped events /// /// `EventWriter` can only send events of one specific type, which must be known at compile-time. /// This is not a problem most of the time, but you may find a situation where you cannot know From 5675dba45b5e9a932fb41763bec1fd796500d64b Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Fri, 22 Dec 2023 07:09:32 +0000 Subject: [PATCH 2/3] Update crates/bevy_ecs/src/event.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: François --- crates/bevy_ecs/src/event.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/bevy_ecs/src/event.rs b/crates/bevy_ecs/src/event.rs index 159611a8eff75..d853db3518249 100644 --- a/crates/bevy_ecs/src/event.rs +++ b/crates/bevy_ecs/src/event.rs @@ -407,6 +407,11 @@ impl DerefMut for EventSequence { } /// Reads events of type `T` in order and tracks which events have already been read. +/// +/// # Concurrency +/// +/// Unlike [`EventWriter`], systems with `EventReader` param can be executed concurrently +/// (but not concurrently with `EventWriter` systems for the same ``). #[derive(SystemParam, Debug)] pub struct EventReader<'w, 's, E: Event> { reader: Local<'s, ManualEventReader>, @@ -484,14 +489,11 @@ impl<'w, 's, E: Event> EventReader<'w, 's, E> { /// # bevy_ecs::system::assert_is_system(my_system); /// ``` /// -/// # Concurrently +/// # Concurrency /// /// `EventWriter` param has [`ResMut>`](Events) inside. So two systems declaring `EventWriter` params /// for the same `` won't be executed concurrently. /// -/// This does not apply to [`EventReader`](EventReader) though: reader systems are executed concurrently -/// (but not with `EventWriter` systems). -/// /// # Untyped events /// /// `EventWriter` can only send events of one specific type, which must be known at compile-time. From 217d6382b910ec5bb288af1208ac58f6f9683a86 Mon Sep 17 00:00:00 2001 From: James Liu Date: Sat, 23 Dec 2023 09:35:24 -0800 Subject: [PATCH 3/3] Avoid using generics in doc comments. --- crates/bevy_ecs/src/event.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_ecs/src/event.rs b/crates/bevy_ecs/src/event.rs index d853db3518249..8b25ab2a2cbc8 100644 --- a/crates/bevy_ecs/src/event.rs +++ b/crates/bevy_ecs/src/event.rs @@ -411,7 +411,7 @@ impl DerefMut for EventSequence { /// # Concurrency /// /// Unlike [`EventWriter`], systems with `EventReader` param can be executed concurrently -/// (but not concurrently with `EventWriter` systems for the same ``). +/// (but not concurrently with `EventWriter` systems for the same event type). #[derive(SystemParam, Debug)] pub struct EventReader<'w, 's, E: Event> { reader: Local<'s, ManualEventReader>, @@ -492,7 +492,7 @@ impl<'w, 's, E: Event> EventReader<'w, 's, E> { /// # Concurrency /// /// `EventWriter` param has [`ResMut>`](Events) inside. So two systems declaring `EventWriter` params -/// for the same `` won't be executed concurrently. +/// for the same event type won't be executed concurrently. /// /// # Untyped events ///