-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
What problem does this solve or what need does it fill?
I have a non-send resource (RustPython
interpreter). It has a sufficiently complicated construction process such that I didn't want to run the constructor in Plugin::build
, but rather have my plugin launch a startup system that would insert the non-send resource.
Right now, the only way to insert a non-send (thread-local) resource is either via AppBuilder
, or via a thread-local system that directly manipulates Resources
.
What solution would you like?
Using the Commands
struct provides a more consistent way of managing resources outside of AppBuilder
. As proposed by RawMeatball here, the API could look like:
fn forced_non_send_system(
commands: &mut Commands,
marker: NonSend<()>,
) {
let custom_thing = Stuff::that_is_non_send();
commands.insert_non_send_resource(&marker, custom_thing);
}
What alternative(s) have you considered?
Could just leave it the way it is. This isn't a necessity, but a nice bit of API consistency.