当前位置: 首页>>代码示例>>C#>>正文


C# Actor.Envelope类代码示例

本文整理汇总了C#中Akka.Actor.Envelope的典型用法代码示例。如果您正苦于以下问题:C# Envelope类的具体用法?C# Envelope怎么用?C# Envelope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Envelope类属于Akka.Actor命名空间,在下文中一共展示了Envelope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Enqueue

 public void Enqueue(IActorRef receiver, Envelope envelope)
 {
     if (!_queue.TryAdd(envelope, PushTimeOut)) // dump messages that can't be delivered in-time into DeadLetters
     {
         receiver.AsInstanceOf<IInternalActorRef>().Provider.DeadLetters.Tell(new DeadLetter(envelope.Message, envelope.Sender, receiver), envelope.Sender);
     }
 }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:7,代码来源:BoundedMessageQueue.cs

示例2: Invoke

        /// <summary>
        ///     Invokes the specified envelope.
        /// </summary>
        /// <param name="envelope">The envelope.</param>
        public void Invoke(Envelope envelope)
        {
            var message = envelope.Message;
            CurrentMessage = message;
            _currentEnvelopeId ++;
            Sender = MatchSender(envelope);

            try
            {
                var autoReceivedMessage = message as IAutoReceivedMessage;
                if (autoReceivedMessage != null)
                    AutoReceiveMessage(envelope);
                else
                    ReceiveMessage(message);
                CurrentMessage = null;
            }
            catch (Exception cause)
            {
                HandleInvokeFailure(cause);
            }
            finally
            {
                CheckReceiveTimeout(); // Reschedule receive timeout
            }
        }
开发者ID:yaozd,项目名称:akka.net,代码行数:29,代码来源:ActorCell.DefaultMessages.cs

示例3: Receive

 /// <summary>
 /// Directly inject messages into actor receive behavior. Any exceptions
 /// thrown will be available to you, while still being able to use
 /// become/unbecome.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="sender">The sender.</param>
 public void Receive(object message, IActorRef sender = null)
 {
     var cell = Cell;
     sender = sender.IsNobody() ? cell.System.DeadLetters : sender;
     var envelope = new Envelope { Message = message, Sender = sender };
     cell.UseThreadContext(() => cell.ReceiveMessageForTest(envelope));
 }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:14,代码来源:InternalTestActorRef.cs

示例4: LockedTryDequeue

 protected override bool LockedTryDequeue(out Envelope envelope)
 {
     if (_prioQueue.Count() > 0)
     {
         envelope = _prioQueue.Dequeue();
         return true;
     }
     envelope = default (Envelope);
     return false;
 }
开发者ID:rodrigovidal,项目名称:akka.net,代码行数:10,代码来源:UnboundedPriorityMailboxQueue.cs

示例5: Enqueue

        public void Enqueue(IActorRef receiver, Envelope envelope)
        {
            if (envelope.Message is DeadLetter)
            {
                // actor subscribing to DeadLetter. Drop it.
                return;
            }

            _deadLetters.Tell(new DeadLetter(envelope.Message, envelope.Sender, receiver), envelope.Sender);
        }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:10,代码来源:DeadLetterMailbox.cs

示例6: TryDequeue

        /// <summary>
        /// Attempt to dequeue a message from the front of the prepend buffer.
        /// 
        /// If the prepend buffer is empty, dequeue a message from the normal
        /// <see cref="MessageQueue"/> wrapped but this wrapper.
        /// </summary>
        /// <param name="envelope">The message to return, if any</param>
        /// <returns><c>true</c> if a message was available, <c>false</c> otherwise.</returns>
        public bool TryDequeue(out Envelope envelope)
        {
            if (_prependBuffer.Count > 0)
            {
                envelope = _prependBuffer.Pop();
                return true;
            }

            return _messageQueue.TryDequeue(out envelope);
        }
开发者ID:MaciekLesiczka,项目名称:akka.net,代码行数:18,代码来源:DequeWrapperMessageQueue.cs

示例7: SendMessage

        public override void SendMessage(Envelope envelope)
        {
            if(!(RouterConfig.IsManagementMessage(envelope.Message)) &&
                resizer.IsTimeForResize(_resizeCounter.GetAndIncrement()) &&
                _resizeInProgress.CompareAndSet(false, true))
            {
                base.SendMessage(new Envelope(new Resize(), Self, System));
            }

            base.SendMessage(envelope);
        }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:11,代码来源:ResizablePoolCell.cs

示例8: Enqueue

  public void Enqueue(Envelope envelope)
  {
      if (PushTimeOut.Milliseconds >= 0)
      {
          _queue.TryAdd(envelope, PushTimeOut);
      }
      else
      {
          _queue.Add(envelope);
      }
 }
开发者ID:MaciekLesiczka,项目名称:akka.net,代码行数:11,代码来源:BoundedMessageQueue.cs

示例9: TryDequeue

 public bool TryDequeue(out Envelope envelope)
 {
     Monitor.TryEnter(_lock, BlockTimeOut);
     try
     {
         return LockedTryDequeue(out envelope);
     }
     finally
     {
         Monitor.Exit(_lock);
     }
 }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:12,代码来源:BlockingMessageQueue.cs

示例10: Enqueue

 public void Enqueue(Envelope envelope)
 {
     Monitor.TryEnter(_lock, BlockTimeOut);
     try
     {
         LockedEnqueue(envelope);
     }
     finally
     {
         Monitor.Exit(_lock);
     }
 }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:12,代码来源:BlockingMessageQueue.cs

示例11: Invoke

        /// <summary>
        ///     Invokes the specified envelope.
        /// </summary>
        /// <param name="envelope">The envelope.</param>
        public void Invoke(Envelope envelope)
        {
            CurrentMessage = envelope.Message;
            Sender = envelope.Sender;
            //set the current context

                try
                {
                    AutoReceiveMessage(envelope);
                }
                catch (Exception cause)
                {
                    Parent.Tell(new Failed(Self, cause));
                }

        }
开发者ID:pdoh00,项目名称:akka.net,代码行数:20,代码来源:ActorCell.DefaultMessages.cs

示例12: autoReceiveMessage

        /*
 def autoReceiveMessage(msg: Envelope): Unit = {
    if (system.settings.DebugAutoReceive)
      publish(Debug(self.path.toString, clazz(actor), "received AutoReceiveMessage " + msg))

    msg.message match {
      case t: Terminated              ⇒ receivedTerminated(t)
      case AddressTerminated(address) ⇒ addressTerminated(address)
      case Kill                       ⇒ throw new ActorKilledException("Kill")
      case PoisonPill                 ⇒ self.stop()
      case sel: ActorSelectionMessage ⇒ receiveSelection(sel)
      case Identify(messageId)        ⇒ sender() ! ActorIdentity(messageId, Some(self))
    }
  }
         */

        protected virtual void AutoReceiveMessage(Envelope envelope)
        {
            var message = envelope.Message;

            var actor = _actor;
            var actorType = actor != null ? actor.GetType() : null;

            if (System.Settings.DebugAutoReceive)
                Publish(new Debug(Self.Path.ToString(), actorType, "received AutoReceiveMessage " + message));

            var m = envelope.Message;
            if (m is Terminated) ReceivedTerminated(m as Terminated);
            else if (m is AddressTerminated) AddressTerminated((m as AddressTerminated).Address);
            else if (m is Kill) Kill();
            else if (m is PoisonPill) HandlePoisonPill();
            else if (m is ActorSelectionMessage) ReceiveSelection(m as ActorSelectionMessage);
            else if (m is Identify) HandleIdentity(m as Identify);
        }
开发者ID:MaciekLesiczka,项目名称:akka.net,代码行数:34,代码来源:ActorCell.DefaultMessages.cs

示例13: autoReceiveMessage

        /*
 def autoReceiveMessage(msg: Envelope): Unit = {
    if (system.settings.DebugAutoReceive)
      publish(Debug(self.path.toString, clazz(actor), "received AutoReceiveMessage " + msg))

    msg.message match {
      case t: Terminated              ⇒ receivedTerminated(t)
      case AddressTerminated(address) ⇒ addressTerminated(address)
      case Kill                       ⇒ throw new ActorKilledException("Kill")
      case PoisonPill                 ⇒ self.stop()
      case sel: ActorSelectionMessage ⇒ receiveSelection(sel)
      case Identify(messageId)        ⇒ sender() ! ActorIdentity(messageId, Some(self))
    }
  }
         */

        protected virtual void AutoReceiveMessage(Envelope envelope)
        {
            var message = envelope.Message;

            var actor = _actor;
            var actorType = actor != null ? actor.GetType() : null;

            if(System.Settings.DebugAutoReceive)
                Publish(new Debug(Self.Path.ToString(), actorType, "received AutoReceiveMessage " + message));

            envelope.Message
                .Match()
                .With<Terminated>(ReceivedTerminated)
                .With<AddressTerminated>(a => AddressTerminated(a.Address))
                .With<Kill>(Kill)
                .With<PoisonPill>(HandlePoisonPill)
                .With<ActorSelectionMessage>(ReceiveSelection)
                .With<Identify>(HandleIdentity);
        }
开发者ID:rodrigovidal,项目名称:akka.net,代码行数:35,代码来源:ActorCell.DefaultMessages.cs

示例14: Post

 public override void Post(IActorRef receiver, Envelope envelope)
 {
     var message = envelope.Message;
     if(message is ISystemMessage)
     {
         Mailbox.DebugPrint("DeadLetterMailbox forwarded system message " + envelope+ " as a DeadLetter");
         _deadLetters.Tell(new DeadLetter(message, receiver, receiver), receiver);
     }
     else if(message is DeadLetter)
     {
         //Just drop it like it's hot
         Mailbox.DebugPrint("DeadLetterMailbox dropped DeadLetter " + envelope);
     }
     else
     {
         Mailbox.DebugPrint("DeadLetterMailbox forwarded message " + envelope + " as a DeadLetter");
         var sender = envelope.Sender;
         _deadLetters.Tell(new DeadLetter(message, sender, receiver),sender);
     }
 }
开发者ID:rogeralsing,项目名称:akka.net,代码行数:20,代码来源:DeadLetterMailbox.cs

示例15: Post

 public override void Post(Envelope envelope)
 {
     var message = envelope.Message;
     if(message is SystemMessage)
     {
         Mailbox.DebugPrint("DeadLetterMailbox forwarded system message " + envelope+ " as a DeadLetter");
         _deadLetters.Tell(new DeadLetter(message, _deadLetters, _deadLetters), _deadLetters);//TODO: When we have refactored Post to SystemEnqueue(ActorRef receiver, Envelope envelope), replace _deadLetters with receiver               
     }
     else if(message is DeadLetter)
     {
         //Just drop it like it's hot
         Mailbox.DebugPrint("DeadLetterMailbox dropped DeadLetter " + envelope);
     }
     else
     {
         Mailbox.DebugPrint("DeadLetterMailbox forwarded message " + envelope + " as a DeadLetter");
         var sender = envelope.Sender;
         _deadLetters.Tell(new DeadLetter(message,sender,_deadLetters),sender);//TODO: When we have refactored Post to Enqueue(ActorRef receiver, Envelope envelope), replace _deadLetters with receiver
     }
 }
开发者ID:ClusterReply,项目名称:akka.net,代码行数:20,代码来源:DeadLetterMailbox.cs


注:本文中的Akka.Actor.Envelope类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。