@@ -14,36 +14,46 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
17
+ use std:: sync:: Arc ;
18
+
17
19
use tracing:: { Span , instrument} ;
18
20
19
21
#[ cfg( target_os = "linux" ) ]
20
22
pub use super :: linux_dirty_page_tracker:: LinuxDirtyPageTracker as PlatformDirtyPageTracker ;
21
- use super :: shared_mem:: SharedMemory ;
23
+ use super :: shared_mem:: HostMapping ;
22
24
#[ cfg( target_os = "windows" ) ]
23
25
pub use super :: windows_dirty_page_tracker:: WindowsDirtyPageTracker as PlatformDirtyPageTracker ;
24
26
use crate :: Result ;
25
27
26
28
/// Trait defining the interface for dirty page tracking implementations
27
29
pub trait DirtyPageTracking {
28
- fn get_dirty_pages ( self ) -> Result < Vec < usize > > ;
30
+ #[ cfg( test) ]
31
+ fn get_dirty_pages ( & self ) -> Result < Vec < usize > > ;
32
+ fn uninstall ( self ) -> Result < Vec < usize > > ;
29
33
}
30
34
31
35
/// Cross-platform dirty page tracker that delegates to platform-specific implementations
36
+ #[ derive( Debug ) ]
32
37
pub struct DirtyPageTracker {
33
38
inner : PlatformDirtyPageTracker ,
34
39
}
35
40
36
41
impl DirtyPageTracker {
37
42
/// Create a new dirty page tracker for the given shared memory
38
43
#[ instrument( skip_all, parent = Span :: current( ) , level = "Trace" ) ]
39
- pub fn new < T : SharedMemory > ( shared_memory : & T ) -> Result < Self > {
40
- let inner = PlatformDirtyPageTracker :: new ( shared_memory ) ?;
44
+ pub fn new ( mapping : Arc < HostMapping > ) -> Result < Self > {
45
+ let inner = PlatformDirtyPageTracker :: new ( mapping ) ?;
41
46
Ok ( Self { inner } )
42
47
}
43
48
}
44
49
45
50
impl DirtyPageTracking for DirtyPageTracker {
46
- fn get_dirty_pages ( self ) -> Result < Vec < usize > > {
51
+ fn uninstall ( self ) -> Result < Vec < usize > > {
52
+ self . inner . stop_tracking_and_get_dirty_pages ( )
53
+ }
54
+
55
+ #[ cfg( test) ]
56
+ fn get_dirty_pages ( & self ) -> Result < Vec < usize > > {
47
57
self . inner . get_dirty_pages ( )
48
58
}
49
59
}
0 commit comments