@@ -32,9 +32,9 @@ pub enum SchedulingAction {
3232
3333/// Timeout callbacks can be created by synchronization primitives to tell the
3434/// scheduler that they should be called once some period of time passes.
35- type TimeoutCallback < ' mir , ' tcx > = Box <
36- dyn FnOnce ( & mut InterpCx < ' mir , ' tcx , MiriMachine < ' mir , ' tcx > > ) -> InterpResult < ' tcx > + ' tcx ,
37- > ;
35+ pub trait TimeoutCallback < ' mir , ' tcx > : VisitMachineValues + ' tcx {
36+ fn call ( & self , ecx : & mut InterpCx < ' mir , ' tcx , MiriMachine < ' mir , ' tcx > > ) -> InterpResult < ' tcx > ;
37+ }
3838
3939/// A thread identifier.
4040#[ derive( Clone , Copy , Debug , PartialOrd , Ord , PartialEq , Eq , Hash ) ]
@@ -252,7 +252,7 @@ struct TimeoutCallbackInfo<'mir, 'tcx> {
252252 /// The callback should be called no earlier than this time.
253253 call_time : Time ,
254254 /// The called function.
255- callback : TimeoutCallback < ' mir , ' tcx > ,
255+ callback : Box < dyn TimeoutCallback < ' mir , ' tcx > > ,
256256}
257257
258258impl < ' mir , ' tcx > std:: fmt:: Debug for TimeoutCallbackInfo < ' mir , ' tcx > {
@@ -542,7 +542,7 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
542542 & mut self ,
543543 thread : ThreadId ,
544544 call_time : Time ,
545- callback : TimeoutCallback < ' mir , ' tcx > ,
545+ callback : Box < dyn TimeoutCallback < ' mir , ' tcx > > ,
546546 ) {
547547 self . timeout_callbacks
548548 . try_insert ( thread, TimeoutCallbackInfo { call_time, callback } )
@@ -558,7 +558,7 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
558558 fn get_ready_callback (
559559 & mut self ,
560560 clock : & Clock ,
561- ) -> Option < ( ThreadId , TimeoutCallback < ' mir , ' tcx > ) > {
561+ ) -> Option < ( ThreadId , Box < dyn TimeoutCallback < ' mir , ' tcx > > ) > {
562562 // We iterate over all threads in the order of their indices because
563563 // this allows us to have a deterministic scheduler.
564564 for thread in self . threads . indices ( ) {
@@ -931,7 +931,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
931931 & mut self ,
932932 thread : ThreadId ,
933933 call_time : Time ,
934- callback : TimeoutCallback < ' mir , ' tcx > ,
934+ callback : Box < dyn TimeoutCallback < ' mir , ' tcx > > ,
935935 ) {
936936 let this = self . eval_context_mut ( ) ;
937937 if !this. machine . communicate ( ) && matches ! ( call_time, Time :: RealTime ( ..) ) {
@@ -970,7 +970,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
970970 // 2. Make the scheduler the only place that can change the active
971971 // thread.
972972 let old_thread = this. set_active_thread ( thread) ;
973- callback ( this) ?;
973+ callback. call ( this) ?;
974974 this. set_active_thread ( old_thread) ;
975975 Ok ( ( ) )
976976 }
0 commit comments