Beispiel #1
0
        public virtual async Task StopBeingProducer()
        {
            if (!_cleanedUpFlag.TrySet())
            {
                return;
            }

            var tasks = _producers.Select(p => p.StopBeingProducer()).ToArray();
            await Task.WhenAll(tasks);
        }
Beispiel #2
0
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposedFlag.TrySet())
     {
         return;
     }
     _onDisposeFunc(Handle);
     Handle.Dispose();
     Handle = null;
 }
Beispiel #3
0
 private void CheckPipelineState(int size, int capacity, InterlockedFlag capacityReached)
 {
     Assert.IsTrue(size >= 0);
     Assert.IsTrue(capacity > 0);
     // a understood flaw of the current algorithm is that the capacity can be exceeded by one item. we've decided that this is acceptable and we allow it to happen.
     Assert.IsTrue(size <= capacity, string.Format("size ({0}) must be less than the capacity ({1})", size, capacity));
     if (capacityReached != null && size == capacity)
     {
         capacityReached.TrySet();
     }
 }
Beispiel #4
0
        public async Task StopBeingProducer()
        {
            if (!_cleanedUpFlag.TrySet())
            {
                return;
            }

            var tasks = new List <Task>();

            foreach (var i in _targets.Distinct())
            {
                tasks.Add(i.StopBeingProducer());
            }
            await Task.WhenAll(tasks);

            tasks = new List <Task>();
            foreach (var i in _targets.Distinct())
            {
                tasks.Add(i.VerifyFinished());
            }
            await Task.WhenAll(tasks);
        }