@@ -32,10 +32,12 @@ pub enum SchedulingAction {
32
32
33
33
/// Timeout callbacks can be created by synchronization primitives to tell the
34
34
/// 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 {
36
36
fn call ( & self , ecx : & mut InterpCx < ' mir , ' tcx , MiriMachine < ' mir , ' tcx > > ) -> InterpResult < ' tcx > ;
37
37
}
38
38
39
+ type TimeoutCallback < ' mir , ' tcx > = Box < dyn MachineCallback < ' mir , ' tcx > + ' tcx > ;
40
+
39
41
/// A thread identifier.
40
42
#[ derive( Clone , Copy , Debug , PartialOrd , Ord , PartialEq , Eq , Hash ) ]
41
43
pub struct ThreadId ( u32 ) ;
@@ -252,7 +254,7 @@ struct TimeoutCallbackInfo<'mir, 'tcx> {
252
254
/// The callback should be called no earlier than this time.
253
255
call_time : Time ,
254
256
/// The called function.
255
- callback : Box < dyn TimeoutCallback < ' mir , ' tcx > > ,
257
+ callback : TimeoutCallback < ' mir , ' tcx > ,
256
258
}
257
259
258
260
impl < ' mir , ' tcx > std:: fmt:: Debug for TimeoutCallbackInfo < ' mir , ' tcx > {
@@ -303,10 +305,10 @@ impl VisitMachineValues for ThreadManager<'_, '_> {
303
305
let ThreadManager {
304
306
threads,
305
307
thread_local_alloc_ids,
308
+ timeout_callbacks,
306
309
active_thread : _,
307
310
yield_active_thread : _,
308
311
sync : _,
309
- timeout_callbacks : _,
310
312
} = self ;
311
313
312
314
for thread in threads {
@@ -315,8 +317,9 @@ impl VisitMachineValues for ThreadManager<'_, '_> {
315
317
for ptr in thread_local_alloc_ids. borrow ( ) . values ( ) . copied ( ) {
316
318
visit. visit ( ptr) ;
317
319
}
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
+ }
320
323
}
321
324
}
322
325
@@ -542,7 +545,7 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
542
545
& mut self ,
543
546
thread : ThreadId ,
544
547
call_time : Time ,
545
- callback : Box < dyn TimeoutCallback < ' mir , ' tcx > > ,
548
+ callback : TimeoutCallback < ' mir , ' tcx > ,
546
549
) {
547
550
self . timeout_callbacks
548
551
. try_insert ( thread, TimeoutCallbackInfo { call_time, callback } )
@@ -558,7 +561,7 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
558
561
fn get_ready_callback (
559
562
& mut self ,
560
563
clock : & Clock ,
561
- ) -> Option < ( ThreadId , Box < dyn TimeoutCallback < ' mir , ' tcx > > ) > {
564
+ ) -> Option < ( ThreadId , TimeoutCallback < ' mir , ' tcx > ) > {
562
565
// We iterate over all threads in the order of their indices because
563
566
// this allows us to have a deterministic scheduler.
564
567
for thread in self . threads . indices ( ) {
@@ -931,7 +934,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
931
934
& mut self ,
932
935
thread : ThreadId ,
933
936
call_time : Time ,
934
- callback : Box < dyn TimeoutCallback < ' mir , ' tcx > > ,
937
+ callback : TimeoutCallback < ' mir , ' tcx > ,
935
938
) {
936
939
let this = self . eval_context_mut ( ) ;
937
940
if !this. machine . communicate ( ) && matches ! ( call_time, Time :: RealTime ( ..) ) {
0 commit comments