1234567891011121314151617181920212223242526272829303132333435363738394041424344open!ImportopenStd_internalopenUnique_id_intfmoduletypeId=Id(* Only "make" can cause a context-switch that might lead to a race.
Thus we have to check whether the contents of the cell remained
unchanged across this call. The subsequent comparison, dereferencing
and assignment cannot cause context switches. If the contents of the
cell had changed, we will have to try again to obtain a unique id.
This is essentially like a spin-lock and is virtually guaranteed to
succeed quickly. *)letrecrace_free_create_loopcellmake=letx=!cellinletnew_x=makexinifphys_equal!cellxthen(cell:=new_x;x)elserace_free_create_loopcellmake;;moduleInt()=structincludeIntletcurrent=refzeroletcreate()=race_free_create_loopcurrentsuccmoduleFor_testing=structletreset_counter()=current:=zeroendendmoduleInt63()=structincludeInt63letcurrent=refzeroletcreate()=race_free_create_loopcurrentsuccmoduleFor_testing=structletreset_counter()=current:=zeroendend