Replies: 1 comment
-
I believe you're right that accessing an /// Forward inbound commands to their processor
pub fn forward_messages(
world: &mut World,
system_state: &mut SystemState<
EventReader<Command>,
Res<ApplicationRegistry>,
Query<&mut Processor>,
>,
) {
let (mut evr, registry, mut q_processor) = system_state.get_mut(world);
// Iterate over all inbound commands
for command in evr.read() {
// Use registry to find which entity will process that command
let target_entity_id = registry.0.get(&command.dst_id()).unwrap();
let mut processor = q_processor.get_mut(target_entity_id).unwrap();
// Add command to that processor queue
processor.queue.push(command.clone());
}
} But at this point you might as well remove the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am building an application where a set of processors can execute commands received from the network. Since command execution can be arbitrarily long, processor components have an internal queue where pending commands are stored. Commands themselves are implemented and registered as one shot systems: processors offer a registering API so developers can register systems to handle specific commands.
I am trying to optimize how commands are routed from the network layer to each target processor internal queue. Currently, the network layer emits "Command" events. I want a routing system to process those events and pushes the associated commands into the target processor queue.
To prevent excessive looping/filtering, I created a "Registry" resource which contains a mapping from a Processor Id to its corresponding entity.
But I am having troubles implementing a "routing" system that leverages that registry. Conceptually, I would like to implement this system:
However, this system signature is a not compliant exclusive system APIs. According to the documentation, I have two alternatives:
world.resource_scope
andSystemState
.I did not manage to read events from an Events resource, so I tried to use
SystemState
. Now, I get borrowing issues because the SystemState query mutably borrowsworld
, so I cannot mutably resolve the entity later on.I found some workarounds but it seems to me I will run into these kind of issues every time I try to use
Entity
. Am I missing something?Beta Was this translation helpful? Give feedback.
All reactions