@@ -48,20 +48,20 @@ pub struct TestTimer {
48
48
end_ms : usize ,
49
49
}
50
50
51
- #[ derive( Debug , Default ) ]
51
+ #[ derive( Clone , Debug , Default ) ]
52
52
pub struct TestClock {
53
53
/// The current time, as advanced, in milliseconds.
54
54
now_ms : Arc < Mutex < usize > > ,
55
55
}
56
56
57
57
impl TestClock {
58
- pub fn advance ( & mut self , milliseconds : usize ) {
59
- let mut locked_now_ms = self . now_ms . lock ( ) . unwrap ( ) ;
60
- * locked_now_ms += milliseconds;
58
+ pub fn now ( & self ) -> usize {
59
+ * self . now_ms . lock ( ) . unwrap ( )
61
60
}
62
61
63
- pub fn access ( & self ) -> Arc < Mutex < usize > > {
64
- self . now_ms . clone ( )
62
+ pub fn advance ( & self , milliseconds : usize ) {
63
+ let mut locked_now_ms = self . now_ms . lock ( ) . unwrap ( ) ;
64
+ * locked_now_ms += milliseconds;
65
65
}
66
66
}
67
67
@@ -70,18 +70,18 @@ impl Clock for TestClock {
70
70
71
71
fn make_timer ( & mut self , milliseconds : usize ) -> Self :: Timer {
72
72
TestTimer {
73
- end_ms : * self . now_ms . lock ( ) . unwrap ( ) + milliseconds,
73
+ end_ms : self . now ( ) + milliseconds,
74
74
}
75
75
}
76
76
77
77
fn is_elapsed ( & mut self , timer : & Self :: Timer ) -> bool {
78
- * self . now_ms . lock ( ) . unwrap ( ) >= timer. end_ms
78
+ self . now ( ) >= timer. end_ms
79
79
}
80
80
81
81
#[ cfg( feature = "debug_ctap" ) ]
82
82
fn timestamp_us ( & mut self ) -> usize {
83
83
// Unused, but let's implement something because it's easy.
84
- * self . now_ms . lock ( ) . unwrap ( ) * 1000
84
+ self . now ( ) * 1000
85
85
}
86
86
}
87
87
0 commit comments