/// <summary> /// Copy write policy from another write policy. /// </summary> public WritePolicy(WritePolicy other) : base(other) { this.recordExistsAction = other.recordExistsAction; this.generationPolicy = other.generationPolicy; this.commitLevel = other.commitLevel; this.generation = other.generation; this.expiration = other.expiration; }
/// <summary> /// Copy write policy from another write policy. /// </summary> public WritePolicy(WritePolicy other) : base(other) { this.recordExistsAction = other.recordExistsAction; this.generationPolicy = other.generationPolicy; this.commitLevel = other.commitLevel; this.generation = other.generation; this.expiration = other.expiration; this.respondAllOps = other.respondAllOps; this.durableDelete = other.durableDelete; }
public void NotifyFor(long position, Action target, CommitLevel level = CommitLevel.Indexed) { long currentPosition; ConcurrentDictionary <long, List <Action> > notificationDictionary; switch (level) { case CommitLevel.Replicated: currentPosition = Interlocked.Read(ref _replicatedPosition); notificationDictionary = _notifyReplicated; break; case CommitLevel.Indexed: currentPosition = Interlocked.Read(ref _indexedPosition); notificationDictionary = _notifyIndexed; break; default: throw new ArgumentOutOfRangeException(nameof(level), level, null); } if (currentPosition >= position) { target(); } if (!notificationDictionary.TryGetValue(position, out var actionList)) { actionList = new List <Action> { target }; notificationDictionary.TryAdd(position, actionList); } else { lock (actionList) { actionList.Add(target); } } }