diff options
author | Enrico Tassi <Enrico.Tassi@inria.fr> | 2016-09-13 09:37:08 +0200 |
---|---|---|
committer | Enrico Tassi <Enrico.Tassi@inria.fr> | 2016-09-13 12:58:07 +0200 |
commit | 5d3718123afed16691843b5d7bcd5841b18f95ac (patch) | |
tree | 00b1e5512d53cfb268a2ca57ca7d718b5459b21c | |
parent | a5fb20b4ad4a56e15455ca329fbc4d03ac5fe072 (diff) |
stm: feedback forwarding has to be atomic
I think that a better place for the mutex would be the printing routine,
but I still hope we will get rid of threads in favor of coroutines.
So I keep all mutexes in Stm.
-rw-r--r-- | stm/stm.ml | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/stm/stm.ml b/stm/stm.ml index cf9fa5492..c53bd958a 100644 --- a/stm/stm.ml +++ b/stm/stm.ml @@ -37,10 +37,12 @@ let state_computed, state_computed_hook = Hook.make let state_ready, state_ready_hook = Hook.make ~default:(fun state_id -> ()) () -let forward_feedback, forward_feedback_hook = Hook.make - ~default:(function +let forward_feedback, forward_feedback_hook = + let m = Mutex.create () in + Hook.make ~default:(function | { id = id; route; contents } -> - feedback ~id:id ~route contents) () + try Mutex.lock m; feedback ~id:id ~route contents; Mutex.unlock m + with e -> Mutex.unlock m; raise e) () let parse_error, parse_error_hook = Hook.make ~default:(fun id loc msg -> |