@@ -188,12 +188,13 @@ public TsavoriteKV(KVSettings<TKey, TValue> kvSettings, TStoreFunctions storeFun
188
188
/// <param name="token">Checkpoint token</param>
189
189
/// <param name="checkpointType">Checkpoint type</param>
190
190
/// <param name="streamingSnapshotIteratorFunctions">Iterator for streaming snapshot records</param>
191
+ /// <param name="cancellationToken">Caller's cancellation token</param>
191
192
/// <returns>
192
193
/// Whether we successfully initiated the checkpoint (initiation may
193
194
/// fail if we are already taking a checkpoint or performing some other
194
195
/// operation such as growing the index). Use CompleteCheckpointAsync to wait completion.
195
196
/// </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 )
197
198
{
198
199
IStateMachine stateMachine ;
199
200
@@ -208,7 +209,7 @@ public bool TryInitiateFullCheckpoint(out Guid token, CheckpointType checkpointT
208
209
{
209
210
stateMachine = Checkpoint . Full ( this , checkpointType , out token ) ;
210
211
}
211
- return stateMachineDriver . Register ( stateMachine ) ;
212
+ return stateMachineDriver . Register ( stateMachine , cancellationToken ) ;
212
213
}
213
214
214
215
/// <summary>
@@ -228,7 +229,7 @@ public bool TryInitiateFullCheckpoint(out Guid token, CheckpointType checkpointT
228
229
public async ValueTask < ( bool success , Guid token ) > TakeFullCheckpointAsync ( CheckpointType checkpointType ,
229
230
CancellationToken cancellationToken = default , IStreamingSnapshotIteratorFunctions < TKey , TValue > streamingSnapshotIteratorFunctions = null )
230
231
{
231
- var success = TryInitiateFullCheckpoint ( out Guid token , checkpointType , streamingSnapshotIteratorFunctions ) ;
232
+ var success = TryInitiateFullCheckpoint ( out Guid token , checkpointType , streamingSnapshotIteratorFunctions , cancellationToken ) ;
232
233
233
234
if ( success )
234
235
await CompleteCheckpointAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
@@ -241,10 +242,10 @@ public bool TryInitiateFullCheckpoint(out Guid token, CheckpointType checkpointT
241
242
/// </summary>
242
243
/// <param name="token">Checkpoint token</param>
243
244
/// <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 )
245
246
{
246
247
var stateMachine = Checkpoint . IndexOnly ( this , out token ) ;
247
- return stateMachineDriver . Register ( stateMachine ) ;
248
+ return stateMachineDriver . Register ( stateMachine , cancellationToken ) ;
248
249
}
249
250
250
251
/// <summary>
@@ -261,7 +262,7 @@ public bool TryInitiateIndexCheckpoint(out Guid token)
261
262
/// </returns>
262
263
public async ValueTask < ( bool success , Guid token ) > TakeIndexCheckpointAsync ( CancellationToken cancellationToken = default )
263
264
{
264
- var success = TryInitiateIndexCheckpoint ( out Guid token ) ;
265
+ var success = TryInitiateIndexCheckpoint ( out Guid token , cancellationToken ) ;
265
266
266
267
if ( success )
267
268
await CompleteCheckpointAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
@@ -277,7 +278,7 @@ public bool TryInitiateIndexCheckpoint(out Guid token)
277
278
/// <param name="tryIncremental">For snapshot, try to store as incremental delta over last snapshot</param>
278
279
/// <returns>Whether we could initiate the checkpoint. Use CompleteCheckpointAsync to wait completion.</returns>
279
280
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 )
281
282
{
282
283
IStateMachine stateMachine ;
283
284
@@ -305,7 +306,7 @@ public bool TryInitiateHybridLogCheckpoint(out Guid token, CheckpointType checkp
305
306
stateMachine = Checkpoint . HybridLogOnly ( this , checkpointType , out token ) ;
306
307
}
307
308
}
308
- return stateMachineDriver . Register ( stateMachine ) ;
309
+ return stateMachineDriver . Register ( stateMachine , cancellationToken ) ;
309
310
}
310
311
311
312
/// <summary>
@@ -340,7 +341,7 @@ public bool CanTakeIncrementalCheckpoint(CheckpointType checkpointType, out Guid
340
341
public async ValueTask < ( bool success , Guid token ) > TakeHybridLogCheckpointAsync ( CheckpointType checkpointType ,
341
342
bool tryIncremental = false , CancellationToken cancellationToken = default )
342
343
{
343
- var success = TryInitiateHybridLogCheckpoint ( out Guid token , checkpointType , tryIncremental ) ;
344
+ var success = TryInitiateHybridLogCheckpoint ( out Guid token , checkpointType , tryIncremental , cancellationToken : cancellationToken ) ;
344
345
345
346
if ( success )
346
347
await CompleteCheckpointAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
0 commit comments