12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667(* This is where we store the widgets that receive the update event *)(* similar to Sync.ml but we make sure there is no repeated entries in the
queue *)(* see: examples/chain *)(* TODO à vider en sortant ? *)(* ou à attacher à la board ? *)openB_utilsmoduleTrigger=B_triggermoduleVar=B_varmoduleWidget=B_widgetletstr=Printf.sprintflettable:(Widget.tlist)Var.t=Var.create[]letis_empty()=Var.gettable=[]letclear()=ifnot(is_empty())thenbeginprintddebug_warning"The update queue was not empty";Var.settable[]endletmemw=List.exists(Widget.equalw)(Var.gettable)letpushw=ifmemwthenprintddebug_event"Widget #%u is already in the Update.table"w.Widget.widelsebeginVar.updatetable(List.consw);Trigger.push_updatew.Widget.wid;endletpush_all()=List.iter(funw->Trigger.push_update(Widget.idw))(Var.gettable)letexecute_oneew=ifw.Widget.wid=Trigger.get_update_widethen(Widget.wake_up_allew;Trigger.push_redraw(Widget.idw)(* OK?? *))letexecutee=matchVar.gettablewith|[]->()(* Optimization (?) we don't want to reset the table to
[] if it was already empty *)|list->(Var.protecttable;letwid=Trigger.get_update_wideinletlist_e,other=List.partition(funw->w.Widget.wid=wid)listinprintddebug_memory"Udpate Table: remaining size=%i"(List.lengthother);(* we keep the widgets that do not correspond to the event e *)Var.unsafe_settableother;Var.releasetable;(* we release the table before execution so that one can still push to
the new table while the old one is being executed *)printddebug_memory"Update Table: execute size=%i"(List.lengthlist_e);List.iter(execute_onee)list_e)