liquidsoap
liquidsoap copied to clipboard
Use atomic wherever possible
The module Atomic provides atomic references, which should be future-proof (compatible with domains). It would be nice to replace mutexes by atomic reference wherever possible...
Unfortunately, the API seems to be missing some kind of functional critical section which makes it difficult to replace some of our use of Mutex
like this:
val mutable outputs = []
val lock = Mutex.create ()
method attach s =
Tutils.mutexify lock
(fun () ->
if not (List.exists (fun (_, s') -> s = s') outputs) then
outputs <- (`New, s) :: outputs)
()