Skip to content

Commit c6b32a2

Browse files
stepanchegmockersfjames7132
authored
Explain EventWriter limits concurrency (#11063)
Co-authored-by: François <[email protected]> Co-authored-by: James Liu <[email protected]>
1 parent dc698f0 commit c6b32a2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

crates/bevy_ecs/src/event.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,11 @@ impl<E: Event> DerefMut for EventSequence<E> {
407407
}
408408

409409
/// Reads events of type `T` in order and tracks which events have already been read.
410+
///
411+
/// # Concurrency
412+
///
413+
/// Unlike [`EventWriter<T>`], systems with `EventReader<T>` param can be executed concurrently
414+
/// (but not concurrently with `EventWriter<T>` systems for the same event type).
410415
#[derive(SystemParam, Debug)]
411416
pub struct EventReader<'w, 's, E: Event> {
412417
reader: Local<'s, ManualEventReader<E>>,
@@ -484,7 +489,12 @@ impl<'w, 's, E: Event> EventReader<'w, 's, E> {
484489
/// # bevy_ecs::system::assert_is_system(my_system);
485490
/// ```
486491
///
487-
/// # Limitations
492+
/// # Concurrency
493+
///
494+
/// `EventWriter` param has [`ResMut<Events<T>>`](Events) inside. So two systems declaring `EventWriter<T>` params
495+
/// for the same event type won't be executed concurrently.
496+
///
497+
/// # Untyped events
488498
///
489499
/// `EventWriter` can only send events of one specific type, which must be known at compile-time.
490500
/// This is not a problem most of the time, but you may find a situation where you cannot know

0 commit comments

Comments
 (0)