Maybe this name isn't the best, but a latch mechanism that can be latched based on a policy:
never release latch (single latch)
release latch every X invocations
release latch every X milliseconds
Possible api:
public interface IReleasePolicy {
bool ShouldRelease();
}
public class Latch<T> {
public Latch(IReleasePolicy releasePolicy, Func<T> work) {}
public T Acquire<T>() {}
public T Acquire<T>(long waitMillis) {}
}
single access guaranteed to the work
time out based acquisition of resource (blockers only or blockers and requester?)
Maybe this name isn't the best, but a latch mechanism that can be latched based on a policy:
Possible api: