本文整理汇总了C#中Akka.Actor.Envelope类的典型用法代码示例。如果您正苦于以下问题:C# Envelope类的具体用法?C# Envelope怎么用?C# Envelope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Envelope类属于Akka.Actor命名空间,在下文中一共展示了Envelope类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: Invoke
/// <summary>
/// Invokes the specified envelope.
/// </summary>
/// <param name="envelope">The envelope.</param>
/// <exception cref="ActorKilledException">
/// This exception is thrown if a <see cref="Akka.Actor.Kill"/> message is included in the given <paramref name="envelope"/>.
/// </exception>>
public void Invoke(Envelope envelope)
{
var message = envelope.Message;
var influenceReceiveTimeout = !(message is INotInfluenceReceiveTimeout);
try
{
// Akka JVM doesn't have these lines
CurrentMessage = envelope.Message;
_currentEnvelopeId++;
Sender = MatchSender(envelope);
if (influenceReceiveTimeout)
{
CancelReceiveTimeout();
}
if (message is IAutoReceivedMessage)
{
AutoReceiveMessage(envelope);
}
else
{
ReceiveMessage(message);
}
CurrentMessage = null;
}
catch (Exception cause)
{
HandleInvokeFailure(cause);
}
finally
{
if (influenceReceiveTimeout)
{
CheckReceiveTimeout(); // Reschedule receive timeout
}
}
}
开发者ID:Micha-kun,项目名称:akka.net,代码行数:48,代码来源:ActorCell.DefaultMessages.cs
示例17: Invoke
/// <summary>
/// Invokes the specified envelope.
/// </summary>
/// <param name="envelope">The envelope.</param>
public void Invoke(Envelope envelope)
{
var message = envelope.Message;
CurrentMessage = message;
Sender = envelope.Sender;
try
{
var autoReceivedMessage = message as AutoReceivedMessage;
if(autoReceivedMessage!=null)
AutoReceiveMessage(envelope);
else
ReceiveMessage(message);
}
catch(Exception cause)
{
Mailbox.Suspend();
Parent.Tell(new Failed(Self, cause));
}
}
开发者ID:jweimann,项目名称:akka.net,代码行数:25,代码来源:ActorCell.DefaultMessages.cs
示例18: LockedEnqueue
protected override void LockedEnqueue(Envelope envelope)
{
_prioQueue.Enqueue(envelope);
}
开发者ID:rodrigovidal,项目名称:akka.net,代码行数:4,代码来源:UnboundedPriorityMailboxQueue.cs
示例19: SystemInvoke
/// <summary>
/// Systems the invoke.
/// </summary>
/// <param name="envelope">The envelope.</param>
public void SystemInvoke(Envelope envelope)
{
try
{
var m = envelope.Message;
if (m is CompleteTask) HandleCompleteTask(m as CompleteTask);
else if (m is Failed) HandleFailed(m as Failed);
else if (m is DeathWatchNotification)
{
var msg = m as DeathWatchNotification;
WatchedActorTerminated(msg.Actor, msg.ExistenceConfirmed, msg.AddressTerminated);
}
else if (m is Create) HandleCreate((m as Create).Failure);
else if (m is Watch)
{
var watch = m as Watch;
AddWatcher(watch.Watchee, watch.Watcher);
}
else if (m is Unwatch)
{
var unwatch = m as Unwatch;
RemWatcher(unwatch.Watchee, unwatch.Watcher);
}
else if (m is Recreate) FaultRecreate((m as Recreate).Cause);
else if (m is Suspend) FaultSuspend();
else if (m is Resume) FaultResume((m as Resume).CausedByFailure);
else if (m is Terminate) Terminate();
else if (m is Supervise)
{
var supervise = m as Supervise;
Supervise(supervise.Child, supervise.Async);
}
else
{
throw new NotSupportedException("Unknown message " + m.GetType().Name);
}
}
catch (Exception cause)
{
HandleInvokeFailure(cause);
}
}
开发者ID:njimenez,项目名称:akka.net,代码行数:48,代码来源:ActorCell.DefaultMessages.cs
示例20: MatchSender
/// <summary>
/// If the envelope.Sender property is null, then we'll substitute
/// Deadletters as the <see cref="Sender"/> of this message.
/// </summary>
/// <param name="envelope">The envelope we received</param>
/// <returns>An IActorRef that corresponds to a Sender</returns>
private IActorRef MatchSender(Envelope envelope)
{
var sender = envelope.Sender;
return sender ?? System.DeadLetters;
}
开发者ID:njimenez,项目名称:akka.net,代码行数:11,代码来源:ActorCell.DefaultMessages.cs
注:本文中的Akka.Actor.Envelope类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论