@@ -32,10 +32,12 @@ 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- pub trait TimeoutCallback < ' mir , ' tcx > : VisitMachineValues + ' tcx {
35+ pub trait MachineCallback < ' mir , ' tcx > : VisitMachineValues {
3636 fn call ( & self , ecx : & mut InterpCx < ' mir , ' tcx , MiriMachine < ' mir , ' tcx > > ) -> InterpResult < ' tcx > ;
3737}
3838
39+ type TimeoutCallback < ' mir , ' tcx > = Box < dyn MachineCallback < ' mir , ' tcx > + ' tcx > ;
40+
3941/// A thread identifier.
4042#[ derive( Clone , Copy , Debug , PartialOrd , Ord , PartialEq , Eq , Hash ) ]
4143pub struct ThreadId ( u32 ) ;
@@ -252,7 +254,7 @@ struct TimeoutCallbackInfo<'mir, 'tcx> {
252254 /// The callback should be called no earlier than this time.
253255 call_time : Time ,
254256 /// The called function.
255- callback : Box < dyn TimeoutCallback < ' mir , ' tcx > > ,
257+ callback : TimeoutCallback < ' mir , ' tcx > ,
256258}
257259
258260impl < ' mir , ' tcx > std:: fmt:: Debug for TimeoutCallbackInfo < ' mir , ' tcx > {
@@ -303,10 +305,10 @@ impl VisitMachineValues for ThreadManager<'_, '_> {
303305 let ThreadManager {
304306 threads,
305307 thread_local_alloc_ids,
308+ timeout_callbacks,
306309 active_thread : _,
307310 yield_active_thread : _,
308311 sync : _,
309- timeout_callbacks : _,
310312 } = self ;
311313
312314 for thread in threads {
@@ -315,8 +317,9 @@ impl VisitMachineValues for ThreadManager<'_, '_> {
315317 for ptr in thread_local_alloc_ids. borrow ( ) . values ( ) . copied ( ) {
316318 visit. visit ( ptr) ;
317319 }
318- // FIXME: Do we need to do something for TimeoutCallback? That's a Box<dyn>, not sure what
319- // to do.
320+ for callback in timeout_callbacks. values ( ) {
321+ callback. callback . visit_machine_values ( visit) ;
322+ }
320323 }
321324}
322325
@@ -542,7 +545,7 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
542545 & mut self ,
543546 thread : ThreadId ,
544547 call_time : Time ,
545- callback : Box < dyn TimeoutCallback < ' mir , ' tcx > > ,
548+ callback : TimeoutCallback < ' mir , ' tcx > ,
546549 ) {
547550 self . timeout_callbacks
548551 . try_insert ( thread, TimeoutCallbackInfo { call_time, callback } )
@@ -558,7 +561,7 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
558561 fn get_ready_callback (
559562 & mut self ,
560563 clock : & Clock ,
561- ) -> Option < ( ThreadId , Box < dyn TimeoutCallback < ' mir , ' tcx > > ) > {
564+ ) -> Option < ( ThreadId , TimeoutCallback < ' mir , ' tcx > ) > {
562565 // We iterate over all threads in the order of their indices because
563566 // this allows us to have a deterministic scheduler.
564567 for thread in self . threads . indices ( ) {
@@ -931,7 +934,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
931934 & mut self ,
932935 thread : ThreadId ,
933936 call_time : Time ,
934- callback : Box < dyn TimeoutCallback < ' mir , ' tcx > > ,
937+ callback : TimeoutCallback < ' mir , ' tcx > ,
935938 ) {
936939 let this = self . eval_context_mut ( ) ;
937940 if !this. machine . communicate ( ) && matches ! ( call_time, Time :: RealTime ( ..) ) {
0 commit comments