Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make Sender state publicly accessible #69

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,16 @@ impl<'a, ES: EventSet> Sender<'a, ES> {
unsafe { self.world.queue_global(ptr, GlobalEventIdx(event_idx)) };
}

/// Grab the state of the sender; the [`EventSet`] indices.
pub fn state(&self) -> &ES::Indices {
self.state
}
Comment on lines +664 to +667
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I would prefer a more specific name for this method.

Suggested change
/// Grab the state of the sender; the [`EventSet`] indices.
pub fn state(&self) -> &ES::Indices {
self.state
}
/// Get a reference to the [`EventSet`] indices of this sender.
pub fn indices(&self) -> &ES::Indices {
self.state
}


/// Grab the world cell.
pub fn world(&self) -> &UnsafeWorldCell<'a> {
&self.world
}
Comment on lines +670 to +672
Copy link
Owner

@rj00a rj00a May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently unsound because UnsafeWorldCell::world is safe to call. Mark UnsafeWorldCell::world as unsafe and we should be good. UnsafeWorldCell should also be made into a HandlerParam at this point.

Edit: Actually, all of the methods on UnsafeWorldCell should be unsafe.


/// Add a [`TargetedEvent`] to the queue of events to send.
///
/// The queue is flushed once all handlers for the current event have run.
Expand Down
2 changes: 1 addition & 1 deletion src/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ impl World {

/// Send all queued events to handlers. The event queue will be empty after
/// this call.
fn flush_event_queue(&mut self) {
pub fn flush_event_queue(&mut self) {
'next_event: while let Some(item) = self.event_queue.pop() {
struct EventDropper<'a> {
event: NonNull<u8>,
Expand Down
Loading