-
Notifications
You must be signed in to change notification settings - Fork 136
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
Error: *const u8
cannot be sent between threads safely
#261
Comments
The compiler is talking about the The cause of the error is that you are trying to access the resources from your system in an incorrect way - instead of trying to pass the whole #[system]
fn update_logic(#[resource] dt: &DeltaTime, #[resource] logic_timer: &mut LogicUpdateTimer) {
logic_timer.update(dt);
// do some logic update stuff...
}
#{system]
fn update_physics(#[resource] dt: &DeltaTime, #[resource] physics_timer: &mut PhysicsUpdateTimer) {
physics_timer.update(dt);
// do some physics update stuff...
}
let mut resources = Resources::default();
resources.insert(DeltaTime::default());
resources.insert(LogicUpdateTimer::default());
resources.insert(PhysicsUpdateTimer::default());
let mut schedule = Schedule::builder()
.add_system(update_logic_system())
.add_system(update_physics_system())
.build();
schedule.execute(&mut world, &mut resources); In the example above, both systems request read access to the same resource ( In your case, it's not yet clear to me how exactly to modify the signature of your |
Thanks a ton Zedrian. That solved my issue. But what if I have multiple variables of the same type that I want to access in my systems? For example, if I have two |
If you have several resources of the same type, but of different usage, you can differ them by creating new wrapper types. Let's assume that in the code snippet that I showed above, both systems are using their own timers that originally were objects of the same type struct LogicUpdateTimer(pub Timer);
struct PhysicsUpdateTimer(pub Timer);
// so instead of this:
resources.insert(Timer::new());
resources.insert(Timer::new()); // that is not okay, you cannot have two resources of the same type
// you can have this:
resources.insert(LogicUpdateTimer(Timer::new());
resources.insert(PhysicsUpdateTimer(Timer::new()); // that is okay, new resource has a different type In this example, I made If you have several resources of the same type and of the same usage, then you should check if something is wrong with the architecture of the solution in general. |
@zedrian |
I'm new to Rust and Legion, and I'm trying to get my
solve_sudoku
system running on a schedule. This is my code.But I'm getting the error message:
I can't for the life of me find where it's even getting
const u8
from -- I don't have any u8's in my code at all. Could you guys help me figure out what I'm missing?The text was updated successfully, but these errors were encountered: