liquidsoap icon indicating copy to clipboard operation
liquidsoap copied to clipboard

Use atomic wherever possible

Open smimram opened this issue 2 years ago • 1 comments

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...

smimram avatar Jun 09 '22 08:06 smimram

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)
        ()

toots avatar Jun 09 '22 14:06 toots