Pausing Coroutine with pending_increment


#1

I’m thinking I don’t understand how this is supposed to work. When I store an InvokedCoroutine and then query its pending count, I expect it to be zero initially. When I call pending_increment, I was expecting the coroutine to pause and to later unpause when decremented to 0.

Here is the test I’m using and the output, the coroutine continues to run until aborted.

!foo : ()[loop[println(GameLib.time_seconds) _wait(1)]]
!co : branch foo()
println("Pending count is " co.pending_count " (expecting 0)")
_wait

co.pending_increment
println("Incrementing pending count, new count: " co.pending_count " (expecting 1)")
_wait

co.pending_decrement
println("Decrementing pending count, new count: " co.pending_count " (expecting 0)")
_wait

co.pending_decrement
println("Decrementing pending count, new count: " co.pending_count " (expecting 0)")
_wait

co.pending_increment
println("Incrementing pending count, new count: " co.pending_count " (expecting 1)")

And I get output:

Pending count is 1 (expecting 0)
Incrementing pending count, new count: 2 (expecting 1)
Decrementing pending count, new count: 1 (expecting 0)
Decrementing pending count, new count: 0 (expecting 0)
Incrementing pending count, new count: 0 (expecting 1)

Can someone explain the expectations vs reality for this one?