コード例 #1
0
 private ResultCompletes(ICompletes clientCompletes, object internalOutcome, bool hasOutcomeSet)
 {
     resultHolder            = this;
     InternalClientCompletes = clientCompletes;
     InternalOutcome         = internalOutcome;
     HasInternalOutcomeSet   = hasOutcomeSet;
 }
コード例 #2
0
        public virtual void Send <T>(Actor actor, Action <T> consumer, ICompletes completes, string representation)
        {
            var messageIndex  = sendIndex.IncrementAndGet();
            var ringSendIndex = (int)(messageIndex % mailboxSize);
            int retries       = 0;

            while (ringSendIndex == (int)(receiveIndex.Get() % mailboxSize))
            {
                if (++retries >= mailboxSize)
                {
                    if (closed.Get())
                    {
                        return;
                    }
                    else
                    {
                        retries = 0;
                    }
                }
            }

            messages[ringSendIndex].Set(actor, consumer, completes, representation);
            while (readyIndex.CompareAndSet(messageIndex - 1, messageIndex))
            {
            }
        }
コード例 #3
0
 Action(object function)
 {
     this.function        = function;
     this.defaultValue    = default(TAct);
     this.hasDefaultValue = false;
     this.nestedCompletes = null;
 }
コード例 #4
0
 Action(object function, ICompletes <TAct> nestedCompletes)
 {
     this.function        = function;
     this.defaultValue    = default(TAct);
     this.hasDefaultValue = false;
     this.nestedCompletes = nestedCompletes;
 }
コード例 #5
0
 Action(object function, TAct defaultValue)
 {
     this.function        = function;
     this.defaultValue    = defaultValue;
     this.hasDefaultValue = true;
     this.nestedCompletes = null;
 }
コード例 #6
0
 Action(object function, TAct defaultValue, ICompletes <TAct> nestedCompletes)
 {
     this.function        = function;
     this.defaultValue    = defaultValue;
     this.hasDefaultValue = true;
     this.nestedCompletes = nestedCompletes;
 }
コード例 #7
0
 public void Set <TConsumer>(Actor actor, Action <TConsumer> consumer, ICompletes completes, string representation)
 {
     this.actor          = actor;
     this.consumer       = (TActor x) => consumer.Invoke((TConsumer)(object)x);
     this.representation = representation;
     this.completes      = completes;
 }
コード例 #8
0
 public LocalMessage(Actor actor, Action <TActor> consumer, ICompletes completes, string representation)
 {
     this.actor          = actor;
     this.consumer       = consumer;
     this.representation = representation;
     this.completes      = completes;
 }
コード例 #9
0
 public PooledCompletes(
     long id,
     ICompletes clientCompletes,
     ICompletesEventually completesEventually)
 {
     Id = id;
     ClientCompletes     = clientCompletes;
     CompletesEventually = completesEventually;
 }
コード例 #10
0
    /// <summary>
    /// Answer my internal <see cref="ICompletes"/> from <c>Completes()</c> after preparing
    /// for the <paramref name="eventualOutcome"/> to be set in my <c>CompletesEventually()</c>.
    /// </summary>
    /// <param name="eventualOutcome">The <see cref="ICompletes"/> the provides an eventual outcome</param>
    /// <typeparam name="TR">The return type of <see cref="ICompletes"/></typeparam>
    /// <returns><see cref="ICompletes"/> of type <typeparamref name="TR"/></returns>
    protected internal ICompletes <TR> AnswerFrom <TR>(ICompletes <TR> eventualOutcome)
    {
        var completes = CompletesEventually();

        eventualOutcome
        .OtherwiseConsume(value => completes.With(value))
        .AndThenConsume(value => completes.With(value));
        return((ICompletes <TR>)Completes());
    }
コード例 #11
0
    public ICompletes <Response> RequestWith(Request request, ICompletes <Response> completes)
    {
        _completesEventually = Stage.World.CompletesFor(completes);

        if (_testId != EmptyTestId)
        {
            request.Headers.Add(RequestHeader.Of(Client.ClientIdCustomHeader, _testId));
            request.Headers.Add(RequestHeader.Of(RequestHeader.XCorrelationID, _testId));
        }

        _requestSender.SendRequest(request);

        StowMessages(typeof(IResponseChannelConsumer));

        return(completes);
    }
        public ICompletes <Response> RequestWith(Request request, ICompletes <Response> completes)
        {
            var correlationId = request.Headers.HeaderOf(RequestHeader.XCorrelationID);

            Request readyRequest;

            if (correlationId == null)
            {
                correlationId = RequestHeader.Of(RequestHeader.XCorrelationID, _randomUuidGenerator.GenerateGuid().ToString());
                readyRequest  = request.And(correlationId);
            }
            else
            {
                readyRequest = request;
            }

            _completables[correlationId !.Value !] = Stage.World.CompletesFor(completes);
コード例 #13
0
        public ICompletes <Response> RequestWith(Request request, ICompletes <Response> completes)
        {
            if (!_actor.IsStopped)
            {
                Action <IClientConsumer> consumer = actor => actor.RequestWith(request, completes);
                var innerCompletes = Completes.Using <Response>(_actor.Scheduler);
                if (_mailbox.IsPreallocated)
                {
                    _mailbox.Send(_actor, consumer, innerCompletes, RequestWithRepresentation1);
                }
                else
                {
                    _mailbox.Send(new LocalMessage <IClientConsumer>(_actor, consumer, innerCompletes, RequestWithRepresentation1));
                }
            }
            else
            {
                _actor.DeadLetters?.FailedDelivery(new DeadLetter(_actor, RequestWithRepresentation1));
            }

            return(null !);
        }
コード例 #14
0
 public ICompletesEventually ProvideCompletesFor(IAddress address, ICompletes clientCompletes)
 {
     ++provideCompletesForCount;
     return(completesEventually);
 }
コード例 #15
0
 public void Send <T>(Actor actor, Action <T> consumer, ICompletes completes, string representation)
 => throw new NotSupportedException("ExecutorDispatcherTest does not support this operation");
コード例 #16
0
 public CompletesEventuallyAdapter(ICompletes <Type> completes)
 {
     _completes = completes;
 }
コード例 #17
0
 private CompletesOutcomeT(ICompletes <IOutcome <TError, T> > value) => _value = value;
コード例 #18
0
 public void Send(Actor actor, Type protocol, LambdaExpression consumer, ICompletes completes, string representation) =>
 throw new NotSupportedException("ExecutorDispatcherTest does not support this operation");
コード例 #19
0
 public StowedLocalMessage(Actor actor, Action <T> consumer, ICompletes <object> completes, string representation)
     : base(actor, consumer, completes, representation)
 {
 }
コード例 #20
0
 public ICompletes <Response> RequestWith(Request request, ICompletes <Response> completes)
 {
     DispatchCommand((a, b, c) => a.RequestWith(b, c), request, completes);
     return(completes);
 }
コード例 #21
0
 public ICompletes <Response> RequestWith(Request request, ICompletes <Response> completes)
 {
     DispatchCommand((consumer, r, c) => consumer.RequestWith(r, c), request, completes);
     return(completes);
 }
コード例 #22
0
ファイル: World.cs プロジェクト: lpedras/vlingo-net-actors
 /// <summary>
 /// Answers a new <see cref="ICompletesEventually"/> instance that backs the <paramref name="clientCompletes"/>.
 /// This manages the <c>ICompletes</c> using the <code>ICompletesEventually</code> plugin <c>Actor</c> pool.
 /// </summary>
 /// <param name="clientCompletes">The <code>ICompletesEventually</code> allocated for eventual completion of <c>clientCompletes</c></param>
 /// <returns></returns>
 public ICompletesEventually CompletesFor(ICompletes clientCompletes)
 => completesProviderKeeper.FindDefault().ProvideCompletesFor(clientCompletes);
コード例 #23
0
ファイル: World.cs プロジェクト: lpedras/vlingo-net-actors
 /// <summary>
 /// Answers a <see cref="ICompletesEventually"/> instance identified by <paramref name="address"/> that backs the <paramref name="clientCompletes"/>.
 /// This manages the <code>ICompletes</code> using the <code>ICompletesEventually</code> plugin <code>Actor</code> pool.
 /// </summary>
 /// <param name="address">The address of the ICompletesEventually actor to reuse.</param>
 /// <param name="clientCompletes">The <code>ICompletesEventually</code> allocated for eventual completion of <code>clientCompletes</code></param>
 /// <returns></returns>
 public ICompletesEventually CompletesFor(IAddress address, ICompletes clientCompletes)
 => completesProviderKeeper.FindDefault().ProvideCompletesFor(address, clientCompletes);
コード例 #24
0
 public override void Reset(ICompletes clientCompletes)
 {
     InternalClientCompletes = clientCompletes;
     InternalOutcome         = null;
     HasInternalOutcomeSet   = false;
 }
コード例 #25
0
 public CompletesAwaiter(ICompletes <T> completes) => _completes = completes;
コード例 #26
0
 /// <summary>
 /// Answer my internal <see cref="ICompletes"/> from <c>Completes()</c> after preparing
 /// for the <paramref name="eventualOutcome"/> to be set in my <c>CompletesEventually()</c>.
 /// </summary>
 /// <param name="eventualOutcome">The <see cref="ICompletes"/> the provides an eventual outcome</param>
 /// <typeparam name="R">The return type of <see cref="ICompletes"/></typeparam>
 /// <returns><see cref="ICompletes"/> of type <typeparamref name="R"/></returns>
 protected internal ICompletes <R> AnswerFrom <R>(ICompletes <R> eventualOutcome)
 {
     eventualOutcome.AndThenConsume(value => CompletesEventually().With(value));
     return((ICompletes <R>)Completes());
 }
コード例 #27
0
 public void Send <T>(Actor actor, Action <T> consumer, ICompletes completes, string representation)
 {
     throw new NotSupportedException("Not a preallocated mailbox.");
 }
コード例 #28
0
 protected internal static Action <TAct> With(object function, ICompletes <TAct> nestedCompletes)
 => new Action <TAct>(function, nestedCompletes);
コード例 #29
0
 public ICompletesEventually ProvideCompletesFor(ICompletes clientCompletes)
 => new PooledCompletes(completesEventuallyId.GetAndIncrement(),
                        clientCompletes,
                        CompletesEventually);
コード例 #30
0
 protected internal static Action <TAct> With(object function, TAct defaultValue, ICompletes <TAct> nestedCompletes)
 => new Action <TAct>(function, defaultValue, nestedCompletes);