Method Lease(string, TimeSpan?, CancellationToken)
that also names the claim it took: identifies this claim of
the key, so that and
act on it only while it is still the one held. A holder
that outlived abandonedAfter and was taken over then confirms or removes nothing of the new
holder's claim.
The default answers without a token, and the token methods then act on the key as
and do.
public Task<IdempotentLease> Lease(string key, TimeSpan? abandonedAfter, CancellationToken ct = default)
Remarks
The confirmed state, the time of the claim and its id are kept with the key; an abandoned claim is replaced by a
compare-and-swap of exactly the entry that was read, so of two callers taking it over at once one wins.