await should not hang the process #83

Closed
opened 2025-07-06 16:45:41 +00:00 by scott · 3 comments
Owner

Two awaits at the end of a process should still let the main process return.

Two awaits at the end of a process should still let the main process return.
Author
Owner

Offending code:

let t1 = spawn_turtle! ()
repeat 4 {
  t1 ::forward! (100)
  t1 ::right! (0.25)
}

let t2 = spawn_turtle! ()
t2 ::pencolor! (:fuchsia)
t2 ::left! (0.125)
t2 ::forward! (100)

await! (t1)
await! (t2)
Offending code: ``` let t1 = spawn_turtle! () repeat 4 { t1 ::forward! (100) t1 ::right! (0.25) } let t2 = spawn_turtle! () t2 ::pencolor! (:fuchsia) t2 ::left! (0.125) t2 ::forward! (100) await! (t1) await! (t2) ```
scott added the
bug
label 2025-07-06 16:51:04 +00:00
scott added this to the Core: CC2 milestone 2025-07-06 16:51:07 +00:00
Author
Owner

Well, this isn't a bug: the turtles stay alive indefinitely.

But this code should work (with a quick modification to the actor-based turtles):

let t1 = spawn_turtle! ()
repeat 4 {
  t1 ::forward! (100)
  t1 ::right! (0.25)
}

let t2 = spawn_turtle! ()
t2 ::pencolor! (:fuchsia)
t2 ::left! (0.125)
t2 ::forward! (100)

t1 ::done ()
t2 ::done ()

await! (t1)
await! (t2)

And yeah, I'm not going to resolve this one tonight, either.

Well, *this* isn't a bug: the turtles stay alive indefinitely. But this code should work (with a quick modification to the actor-based turtles): ``` let t1 = spawn_turtle! () repeat 4 { t1 ::forward! (100) t1 ::right! (0.25) } let t2 = spawn_turtle! () t2 ::pencolor! (:fuchsia) t2 ::left! (0.125) t2 ::forward! (100) t1 ::done () t2 ::done () await! (t1) await! (t2) ``` And yeah, I'm not going to resolve this one tonight, either.
Author
Owner

Ah, but this is a limitation in how I wrote the turtle listener: instead of the recursive call coming after every clause in the receive form, I put the recursive call unconditionally at the end. So while this is a "bug," it's actually just a (bad?) design decision.

So: yeah, closing this out because it's not another bug in await, thankfully.

Ah, but this is a limitation in how I wrote the turtle listener: instead of the recursive call coming after *every* clause in the `receive` form, I put the recursive call unconditionally at the end. So while this is a "bug," it's actually just a (bad?) design decision. So: yeah, closing this out because it's *not* another bug in await, thankfully.
scott closed this issue 2025-07-07 03:02:29 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: twc/ludus#83
No description provided.