/// <summary> /// Tries to get output value source from current entity. /// </summary> /// <returns>New output source with the same queue as in current entity in exclusive mode or with new queue in non-exclusive mode.</returns> internal IValueSource TakeValueSource() { lock (_lockGuard) { NotifyingQueue <object> queue; if (_exclusiveModeEnabled) { queue = _globalSource.Queue; } else { queue = new NotifyingQueue <object>(_queueSize); } var source = new OutputSource(_valueType, queue); source.OutputUnlocked += () => { if (!IsLocked) { OutputUnlocked?.Invoke(); } }; _sources.Add(source); return(source); } }
/// <summary> /// Event handler method for QueueUnlocked event fired by inner queue. /// </summary> private void QueueUnlocked() { OutputUnlocked?.Invoke(); }