possibly concurrent turtle updates
This commit is contained in:
parent
8660daad1d
commit
c5499b0277
2 changed files with 3 additions and 3 deletions
|
@ -292,14 +292,14 @@ impl TurtleCommander {
|
|||
|
||||
pub(crate) async fn process_turtle_update(
|
||||
id: u32,
|
||||
state: &mut LiveState,
|
||||
state: &LiveState,
|
||||
update: TurtleUpdate,
|
||||
) -> anyhow::Result<TurtleCommand> {
|
||||
let mut turtle = state
|
||||
.turtles
|
||||
.get(id as usize)
|
||||
.context("nonexisting turtle")?.write().await;
|
||||
let world = &mut state.world;
|
||||
let world = &state.world;
|
||||
|
||||
if turtle.pending_update {
|
||||
turtle.pending_update = false;
|
||||
|
|
|
@ -150,7 +150,7 @@ pub(crate) async fn command(
|
|||
State(state): State<SharedControl>,
|
||||
Json(req): Json<turtle::TurtleUpdate>,
|
||||
) -> Json<turtle::TurtleCommand> {
|
||||
let mut state = &mut state.write().await;
|
||||
let mut state = &mut state.read().await;
|
||||
|
||||
if id as usize > state.turtles.len() {
|
||||
return Json(turtle::TurtleCommand::Update);
|
||||
|
|
Loading…
Reference in a new issue