@@ -14,36 +14,46 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17+ use std:: sync:: Arc ;
18+
1719use tracing:: { Span , instrument} ;
1820
1921#[ cfg( target_os = "linux" ) ]
2022pub use super :: linux_dirty_page_tracker:: LinuxDirtyPageTracker as PlatformDirtyPageTracker ;
21- use super :: shared_mem:: SharedMemory ;
23+ use super :: shared_mem:: HostMapping ;
2224#[ cfg( target_os = "windows" ) ]
2325pub use super :: windows_dirty_page_tracker:: WindowsDirtyPageTracker as PlatformDirtyPageTracker ;
2426use crate :: Result ;
2527
2628/// Trait defining the interface for dirty page tracking implementations
2729pub 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 > > ;
2933}
3034
3135/// Cross-platform dirty page tracker that delegates to platform-specific implementations
36+ #[ derive( Debug ) ]
3237pub struct DirtyPageTracker {
3338 inner : PlatformDirtyPageTracker ,
3439}
3540
3641impl DirtyPageTracker {
3742 /// Create a new dirty page tracker for the given shared memory
3843 #[ 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 ) ?;
4146 Ok ( Self { inner } )
4247 }
4348}
4449
4550impl 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 > > {
4757 self . inner . get_dirty_pages ( )
4858 }
4959}
0 commit comments