示例#1
0
        public void A_locked_read_should_work()
        {
            string value = string.Empty;

            _value.ReadLock(x => { value = x; });

            Assert.AreEqual(_initialValue, value);
            //Assert.That(value, Is.EqualTo(_initialValue));
        }
示例#2
0
 public IEnumerable <Action <TMessage> > Enumerate(TMessage message)
 {
     foreach (var sink in _sinks.ReadLock(x => x.ToArray()))
     {
         foreach (var consumer in sink.Enumerate(message))
         {
             yield return(consumer);
         }
     }
 }
示例#3
0
        public virtual bool Inspect(IPipelineInspector inspector)
        {
            return(inspector.Inspect(this, () =>
            {
                foreach (IPipelineSink <TMessage> sink in _sinks.ReadLock(x => x.Values))
                {
                    if (sink.Inspect(inspector) == false)
                    {
                        return false;
                    }
                }

                return true;
            }));
        }
        public bool IsRetryLimitExceeded(string id)
        {
            int retryCount = 0;

            if (!_messages.ReadLock(x => x.TryGetValue(id, out retryCount)))
            {
                return(false);
            }

            return(retryCount >= _retryLimit);
        }
示例#5
0
        public override IEnumerable <Action <TMessage> > Enumerate(TMessage message)
        {
            IPipelineSink <TMessage> sink = null;

            _sinks.UpgradeableReadLock(x =>
            {
                if (x.TryGetValue(message.BatchId, out sink) == false)
                {
                    _sinks.WriteLock(y =>
                    {
                        if (x.TryGetValue(message.BatchId, out sink) == false)
                        {
                            _log.Debug("Adding a new message router for batchId " + message.BatchId);
                            var batchMessage = new Batch <TMessage, TBatchId>(message.BatchId, message.BatchLength, null);

                            // we need to create a sink for this batch and get it wired up
                            var router = new MessageRouter <TMessage>();
                            foreach (var messageSink in _consumerSinks.ReadLock(z => z))
                            {
                                foreach (var consumes in messageSink.Enumerate(batchMessage))
                                {
                                    router.Connect(new BatchCombiner <TMessage, TBatchId>(message.BatchId, message.BatchLength, consumes));
                                }
                            }

                            x.Add(message.BatchId, router);

                            sink = router;
                        }
                    });
                }
            });

            if (sink == null)
            {
                yield break;
            }

            foreach (var consumer in sink.Enumerate(message))
            {
                yield return(consumer);
            }
        }
 public void Each(Action <T> action)
 {
     _items.ReadLock(x => x.ForEach(action));
 }
 public int PendingMessageCount()
 {
     return(_messages.ReadLock(x => x.Count));
 }
        private IEndpointFactory Create()
        {
            IEndpointFactory endpointFactory = new EndpointFactory(_objectBuilder, _defaultSerializer, _transportTypes.ReadLock(x => x), _endpointConfigurators);

            return(endpointFactory);
        }