theolaurent / ocaml-reagent

An implementation of reagents for multicore OCaml
ISC License
4 stars 0 forks source link

Correct semantics of reference update #13

Open kayceesrk opened 9 years ago

kayceesrk commented 9 years ago

update r f should block if f returns None instead of failing forever with never. The thread performing the update should be woken up when the reference is updated. This is similar to an STM's commit log.

theolaurent commented 9 years ago

I changed the update reagent into something else for now. It no longer takes a "partial" function. And is just syntactic sugar on CAS (and computed). Maybe it should be renamed, but this one is super useful anyway.

As for the "real" update reagent it should not use usual CAS references. (maybe a "state" data structure?)

kayceesrk commented 9 years ago

Yeah. If we do call it State, we should clearly distinguish from Ref since both modules provide the same interface (read, cas, update, etc) but their semantics are very different. While Ref is non-blocking, State is blocking.

theolaurent commented 9 years ago

Sounds good to me.