input-output-hk / io-sim

Haskell's IO simulator which closely follows core packages (base, async, stm).
https://hackage.haskell.org/package/io-sim
Apache License 2.0
37 stars 15 forks source link

threadDelay: efficiently remove thread delay timer #86

Closed coot closed 1 year ago

coot commented 1 year ago

Unfortunately we cannot track the information on which ThreadDelay a thread is blocked in threadStatus because it is cleared when a thread is rescheduled. This is too early. In the scenario we are interested in, the thread is rescheduled when the thread receives an exception and it's when we interpret the Throw we need to know the TimeoutId of that threadDelay.

We add a threadDelayId field, which tracks the last threadDelay id. This field only cleared when the thread receives an exception, thus it's life time is long enough to be useful.

coot commented 1 year ago

I hope the noise isn't too laud :grin:.