-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Expose the event bump allocator. #44
Comments
This would be amazing, especially for what I am doing with https://github.com/andrewgazelka/hyperion. Just ran into this issue recently. |
Can you lay out more specifics for how you think this will be done? For instance, will there be a new handler parameter that is specifically used to obtain the bump allocator? Such as a struct named |
I'm not sure exactly. |
Are you sure So, since everything is not |
Yeah since |
This PR removes the `'static` requirement from `Sender::send` and `Sender::send_to` and exposes the bump allocator by providing allocation methods on `Sender`. `Sender` is now entirely internally mutable (takes `&self` on all the methods). This partially addresses #44 but is missing a few things. - Doesn't allow received events with borrowed data to pass though `Sender::send` without a clone because `Receiver` and `Sender` have different lifetimes. Might still need a combined `Sender` and `Receiver` type. - Can't use the bump allocator from a `&mut World`. - No optional `collections` module. I think it would be easier to just add an unstable feature for the unstable allocator api for those who need it.
For reasons of efficiency, events in
evenio
are allocated in abumpalo
bump allocator. This allocator is cleared once the top levelWorld::send
call returns. It would be useful if users had access to this arena for their own purposes. It should be possible for events to safely contain data borrowed from the allocator, which would eliminate the need for heap allocations in many cases.Essentially, we remove the
'static
requirement fromSender::send
and replace it with, say,'e
representing the lifetime of data allocated from the arena. I would expect the'e
lifetime to carry through received events as well, so that data from a received event can be stuffed into a sent event without cloning.There's also the issue of collections. Custom allocators are still nightly-only, so we would have to fork the standard collections as bumpalo does. I would expect this to be available behind a non-default feature flag.
If #43 happens then I'm guessing we would need a
'w: 'e
bound somewhere.Requirements
bumpalo
crate are not exposed in the public API directly.&mut World
context.collections
module.The text was updated successfully, but these errors were encountered: