theolaurent / ocaml-reagent

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

MSQueue pop should return an option type #4

Closed kayceesrk closed 9 years ago

kayceesrk commented 9 years ago

Should MSQueue pop [1] return a (unit, 'a option) Reagent.t instead of retrying? Then, I can build a non-blocking pop using computed reagent as follows:

let rec pop_nb (q : 'a t) : (unit, 'a) Reagent.t =
  pop q >> Reagent.computed (fun v =>
    match v with
    | Some v -> Reagent.constant v
    | None -> Reagent.retry)

[1] https://github.com/theolaurent/ocaml-reagent/blob/master/core/MSQueue.mli#L8