News for hackers. Stuff that matters.
Re:Show HN: State Trooper – Tiny, no frills state machine fo... by rowls66 on Saturday June 17, 2023 @12:53PM (#36371965)
Interesting. I wrote almost the same code for work a couple of weeks ago.

Not sore, but it looks like the Transition function has a race condition. It calls CanTansition() before acquiring the mutex lock. I think this could lead to illegal state transitions.

Re:Show HN: State Trooper – Tiny, no frills state machine fo... by hishamk on Saturday June 17, 2023 @03:29PM (#36373690)
Thanks for this. You are indeed correct. I've pushed a fix and also added a race test to confirm the fix.
Re:Show HN: State Trooper – Tiny, no frills state machine fo... by hmcamp on Sunday June 18, 2023 @04:37AM (#36378385)
Good eye! Thanks for pointing this out.