@@ -188,12 +188,13 @@ public TsavoriteKV(KVSettings<TKey, TValue> kvSettings, TStoreFunctions storeFun
188188 /// <param name="token">Checkpoint token</param>
189189 /// <param name="checkpointType">Checkpoint type</param>
190190 /// <param name="streamingSnapshotIteratorFunctions">Iterator for streaming snapshot records</param>
191+ /// <param name="cancellationToken">Caller's cancellation token</param>
191192 /// <returns>
192193 /// Whether we successfully initiated the checkpoint (initiation may
193194 /// fail if we are already taking a checkpoint or performing some other
194195 /// operation such as growing the index). Use CompleteCheckpointAsync to wait completion.
195196 /// </returns>
196- public bool TryInitiateFullCheckpoint ( out Guid token , CheckpointType checkpointType , IStreamingSnapshotIteratorFunctions < TKey , TValue > streamingSnapshotIteratorFunctions = null )
197+ public bool TryInitiateFullCheckpoint ( out Guid token , CheckpointType checkpointType , IStreamingSnapshotIteratorFunctions < TKey , TValue > streamingSnapshotIteratorFunctions = null , CancellationToken cancellationToken = default )
197198 {
198199 IStateMachine stateMachine ;
199200
@@ -208,7 +209,7 @@ public bool TryInitiateFullCheckpoint(out Guid token, CheckpointType checkpointT
208209 {
209210 stateMachine = Checkpoint . Full ( this , checkpointType , out token ) ;
210211 }
211- return stateMachineDriver . Register ( stateMachine ) ;
212+ return stateMachineDriver . Register ( stateMachine , cancellationToken ) ;
212213 }
213214
214215 /// <summary>
@@ -228,7 +229,7 @@ public bool TryInitiateFullCheckpoint(out Guid token, CheckpointType checkpointT
228229 public async ValueTask < ( bool success , Guid token ) > TakeFullCheckpointAsync ( CheckpointType checkpointType ,
229230 CancellationToken cancellationToken = default , IStreamingSnapshotIteratorFunctions < TKey , TValue > streamingSnapshotIteratorFunctions = null )
230231 {
231- var success = TryInitiateFullCheckpoint ( out Guid token , checkpointType , streamingSnapshotIteratorFunctions ) ;
232+ var success = TryInitiateFullCheckpoint ( out Guid token , checkpointType , streamingSnapshotIteratorFunctions , cancellationToken ) ;
232233
233234 if ( success )
234235 await CompleteCheckpointAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
@@ -241,10 +242,10 @@ public bool TryInitiateFullCheckpoint(out Guid token, CheckpointType checkpointT
241242 /// </summary>
242243 /// <param name="token">Checkpoint token</param>
243244 /// <returns>Whether we could initiate the checkpoint. Use CompleteCheckpointAsync to wait completion.</returns>
244- public bool TryInitiateIndexCheckpoint ( out Guid token )
245+ public bool TryInitiateIndexCheckpoint ( out Guid token , CancellationToken cancellationToken = default )
245246 {
246247 var stateMachine = Checkpoint . IndexOnly ( this , out token ) ;
247- return stateMachineDriver . Register ( stateMachine ) ;
248+ return stateMachineDriver . Register ( stateMachine , cancellationToken ) ;
248249 }
249250
250251 /// <summary>
@@ -261,7 +262,7 @@ public bool TryInitiateIndexCheckpoint(out Guid token)
261262 /// </returns>
262263 public async ValueTask < ( bool success , Guid token ) > TakeIndexCheckpointAsync ( CancellationToken cancellationToken = default )
263264 {
264- var success = TryInitiateIndexCheckpoint ( out Guid token ) ;
265+ var success = TryInitiateIndexCheckpoint ( out Guid token , cancellationToken ) ;
265266
266267 if ( success )
267268 await CompleteCheckpointAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
@@ -277,7 +278,7 @@ public bool TryInitiateIndexCheckpoint(out Guid token)
277278 /// <param name="tryIncremental">For snapshot, try to store as incremental delta over last snapshot</param>
278279 /// <returns>Whether we could initiate the checkpoint. Use CompleteCheckpointAsync to wait completion.</returns>
279280 public bool TryInitiateHybridLogCheckpoint ( out Guid token , CheckpointType checkpointType , bool tryIncremental = false ,
280- IStreamingSnapshotIteratorFunctions < TKey , TValue > streamingSnapshotIteratorFunctions = null )
281+ IStreamingSnapshotIteratorFunctions < TKey , TValue > streamingSnapshotIteratorFunctions = null , CancellationToken cancellationToken = default )
281282 {
282283 IStateMachine stateMachine ;
283284
@@ -305,7 +306,7 @@ public bool TryInitiateHybridLogCheckpoint(out Guid token, CheckpointType checkp
305306 stateMachine = Checkpoint . HybridLogOnly ( this , checkpointType , out token ) ;
306307 }
307308 }
308- return stateMachineDriver . Register ( stateMachine ) ;
309+ return stateMachineDriver . Register ( stateMachine , cancellationToken ) ;
309310 }
310311
311312 /// <summary>
@@ -340,7 +341,7 @@ public bool CanTakeIncrementalCheckpoint(CheckpointType checkpointType, out Guid
340341 public async ValueTask < ( bool success , Guid token ) > TakeHybridLogCheckpointAsync ( CheckpointType checkpointType ,
341342 bool tryIncremental = false , CancellationToken cancellationToken = default )
342343 {
343- var success = TryInitiateHybridLogCheckpoint ( out Guid token , checkpointType , tryIncremental ) ;
344+ var success = TryInitiateHybridLogCheckpoint ( out Guid token , checkpointType , tryIncremental , cancellationToken : cancellationToken ) ;
344345
345346 if ( success )
346347 await CompleteCheckpointAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
0 commit comments