I have unsafe code (a writer for shared data) that can only be called from multiple threads in a serialized way, but I don’t want to block any other thread-safe work (multiple readers) when this code is not called.
This, in fact, is a situation of blocking of the type of multiple reading / single writer, where writers should exclude both readers and other authors.
i.e. I have two functions:
(defn reader-function [] ....)
(defn writer-function [] ....)
And the number of threads that are executed (possibly in a loop) are as follows:
(do
(reader-function)
...
(writer-function))
If any one thread has a write function, all other threads should be blocked. that is, at any moment in time:
- one thread is executed by the writer and all others are blocked
- , ,
, .
Clojure?