What's a good approach to extending a TVar to support change-notification? i.e., allow another thread to get notified when the TVar changes.
My current approach,
-- A mutable variable with change notification---- one subscriber only (because of TMVar)dataChanginga=Changing{-- | Current valuechangingCurrent::TMVara,-- | To get notified of whenever the value changes.---- Only one reader is supported.changingUpdated::TMVar()}
By the way, for the record - this type has evolved to support multiple subscribers - almost resembling pubsub - but with unit value being published (because actual value is in the other TVar).
What's a good approach to extending a
TVar
to support change-notification? i.e., allow another thread to get notified when the TVar changes.My current approach,
https://github.com/srid/ema/blob/69c292f0f326cc572fd3975fb256ab821eb9ab75/src/Ema/Changing.hs
By the way, for the record - this type has evolved to support multiple subscribers - almost resembling pubsub - but with
unit
value being published (because actual value is in the other TVar).https://github.com/srid/ema/blob/593bc9c49e3e77a54ed3f082bfb42e1b174b154e/src/Ema/Changing.hs
Not happy with how it looks, abstraction wise. Looks a bit messy, the code.
Introducing
LVar
https://github.com/srid/ema/blob/master/src/Data/LVar.hs
Should soon be a library.