To avoid that multiple processes share the same reconfiguration signal, we can associate an id to each extensible process and dispatch the requests.

The adding requests will be sent on the signal to_add with the id of the process to extend.

signal to_add ;;

Each extensible process has its own add_behavior signal and filters the to_add signal to extract only those requests addressed to it.

let process extensible p_init state =
  let id = gen_id () in
  print_endline ("{"^(string_of_int id)^"}");
  signal add_behavior default (fun state -> process ())
    gather
     (fun p q state -> process (run (p state) || run (q state)))
  in
  run (extend p_init state add_behavior)
  ||
  loop
    await to_add(reqs) in
    List.iter
     (fun (x, p) -> if x = id then emit add_behavior p)
     reqs
  end