@@ -32,9 +32,9 @@ 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
- 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
+ }
38
38
39
39
/// A thread identifier.
40
40
#[ derive( Clone , Copy , Debug , PartialOrd , Ord , PartialEq , Eq , Hash ) ]
@@ -252,7 +252,7 @@ struct TimeoutCallbackInfo<'mir, 'tcx> {
252
252
/// The callback should be called no earlier than this time.
253
253
call_time : Time ,
254
254
/// The called function.
255
- callback : TimeoutCallback < ' mir , ' tcx > ,
255
+ callback : Box < dyn TimeoutCallback < ' mir , ' tcx > > ,
256
256
}
257
257
258
258
impl < ' mir , ' tcx > std:: fmt:: Debug for TimeoutCallbackInfo < ' mir , ' tcx > {
@@ -542,7 +542,7 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
542
542
& mut self ,
543
543
thread : ThreadId ,
544
544
call_time : Time ,
545
- callback : TimeoutCallback < ' mir , ' tcx > ,
545
+ callback : Box < dyn TimeoutCallback < ' mir , ' tcx > > ,
546
546
) {
547
547
self . timeout_callbacks
548
548
. try_insert ( thread, TimeoutCallbackInfo { call_time, callback } )
@@ -558,7 +558,7 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
558
558
fn get_ready_callback (
559
559
& mut self ,
560
560
clock : & Clock ,
561
- ) -> Option < ( ThreadId , TimeoutCallback < ' mir , ' tcx > ) > {
561
+ ) -> Option < ( ThreadId , Box < dyn TimeoutCallback < ' mir , ' tcx > > ) > {
562
562
// We iterate over all threads in the order of their indices because
563
563
// this allows us to have a deterministic scheduler.
564
564
for thread in self . threads . indices ( ) {
@@ -931,7 +931,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
931
931
& mut self ,
932
932
thread : ThreadId ,
933
933
call_time : Time ,
934
- callback : TimeoutCallback < ' mir , ' tcx > ,
934
+ callback : Box < dyn TimeoutCallback < ' mir , ' tcx > > ,
935
935
) {
936
936
let this = self . eval_context_mut ( ) ;
937
937
if !this. machine . communicate ( ) && matches ! ( call_time, Time :: RealTime ( ..) ) {
@@ -970,7 +970,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
970
970
// 2. Make the scheduler the only place that can change the active
971
971
// thread.
972
972
let old_thread = this. set_active_thread ( thread) ;
973
- callback ( this) ?;
973
+ callback. call ( this) ?;
974
974
this. set_active_thread ( old_thread) ;
975
975
Ok ( ( ) )
976
976
}
0 commit comments