Skip to content

Commit

Permalink
Better clock filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Nov 19, 2024
1 parent cf3fd62 commit df2b1b2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/core/clock.ml
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,22 @@ let sources c =
@ Queue.elements outputs
| _ -> []

(* Return the clock effective sync. Stopped clocks can
be unified with any active type clocks so [`Stopped _] returns
[`Stopped]. *)
let _sync ?(pending = false) x =
match Atomic.get x.state with
| `Stopped p when pending -> (p :> sync_mode)
| `Stopped _ -> `Stopped
| `Stopping _ -> `Stopping
| `Started { sync } -> (sync :> sync_mode)

(* Return the current sync, used to make decisions based on the
clock's sync value, regardless of potential unification. *)
let active_sync_mode c =
match Atomic.get (Unifier.deref c).state with
| `Stopped sync | `Stopping { sync } | `Started { sync } -> sync

let sync c = _sync (Unifier.deref c)
let cleanup_source s = try s#force_sleep with _ -> ()
let clocks = Queue.create ()
Expand Down Expand Up @@ -261,7 +270,7 @@ let unify =
Queue.flush_iter clock.on_error (Queue.push clock'.on_error);
Unifier.(clock.id <-- clock'.id);
Unifier.(c <-- c');
Queue.filter clocks (fun el -> sync el <> `Passive && el != c)
Queue.filter clocks (fun el -> active_sync_mode el <> `Passive && el != c)
in
fun ~pos c c' ->
let _c = Unifier.deref c in
Expand Down

0 comments on commit df2b1b2

Please sign in to comment.