本文整理汇总了C#中IActorRef.AsInstanceOf方法的典型用法代码示例。如果您正苦于以下问题:C# IActorRef.AsInstanceOf方法的具体用法?C# IActorRef.AsInstanceOf怎么用?C# IActorRef.AsInstanceOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IActorRef
的用法示例。
在下文中一共展示了IActorRef.AsInstanceOf方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Send
public override void Send(object message, IActorRef sender)
{
if (sender is LocalActorRef)
{
sender.AsInstanceOf<LocalActorRef>().Provider.DeadLetters.Tell(message);
}
}
示例2: 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);
}
}
示例3: Setup
public void Setup(BenchmarkContext context)
{
MsgReceived = context.GetCounter("MsgReceived");
System = ActorSystem.Create("PerfSys", Config);
int count = 0;
Action<IActorDsl> actor = d => d.ReceiveAny((o, c) =>
{
MsgReceived.Increment();
count++;
if(count == ExpectedMessages)
ResetEvent.Set();
});
TestActor = System.ActorOf(Props.Create(() => new Act(actor)).WithDispatcher("calling-thread-dispatcher"), "testactor");
SpinWait.SpinUntil(() => TestActor.AsInstanceOf<RepointableActorRef>().IsStarted);
// force initialization of the actor
for(var i = 0; i < ExpectedMessages-1;i++)
TestActor.AsInstanceOf<RepointableActorRef>().Underlying.AsInstanceOf<ActorCell>().Mailbox.MessageQueue.Enqueue(TestActor, new Envelope("hit", ActorRefs.Nobody)); // queue all of the messages into the actor
}
示例4: Setup
public void Setup(BenchmarkContext context)
{
MsgReceived = context.GetCounter("MsgReceived");
System = ActorSystem.Create("PerfSys");
Action<IActorDsl> actor = d => d.ReceiveAny((o, c) =>
{
MsgReceived.Increment();
});
TestActor = System.ActorOf(Props.Create(() => new Act(actor)), "testactor");
var id = TestActor.Ask<ActorIdentity>(new Identify(null), TimeSpan.FromSeconds(3)).Result;
Mailbox = new Mailbox(new UnboundedMessageQueue());
Mailbox.SetActor(TestActor.AsInstanceOf<RepointableActorRef>().Underlying.AsInstanceOf<ActorCell>());
}
示例5: Recurse
private static ImmutableList<IActorRef> Recurse(IActorRef @ref)
{
var empty = new List<IActorRef>();
var list = empty;
if (@ref is ActorRefWithCell)
{
var cell = @ref.AsInstanceOf<ActorRefWithCell>().Underlying;
if (cell.ChildrenContainer is EmptyChildrenContainer ||
cell.ChildrenContainer is TerminatedChildrenContainer ||
cell.ChildrenContainer is TerminatingChildrenContainer) list = empty;
else list = cell.ChildrenContainer.Children.Cast<IActorRef>().ToList();
}
return ImmutableList<IActorRef>.Empty.Add(@ref).AddRange(list.SelectMany(Recurse));
}
示例6: SerializedActorPath
public static string SerializedActorPath(IActorRef @ref)
{
/*
val path = actorRef.path
val originalSystem: ExtendedActorSystem = actorRef match {
case a: ActorRefWithCell ⇒ a.underlying.system.asInstanceOf[ExtendedActorSystem]
case _ ⇒ null
}
Serialization.currentTransportInformation.value match {
case null ⇒ originalSystem match {
case null ⇒ path.toSerializationFormat
case system ⇒
try path.toSerializationFormatWithAddress(system.provider.getDefaultAddress)
catch { case NonFatal(_) ⇒ path.toSerializationFormat }
}
case Information(address, system) ⇒
if (originalSystem == null || originalSystem == system)
path.toSerializationFormatWithAddress(address)
else {
val provider = originalSystem.provider
path.toSerializationFormatWithAddress(provider.getExternalAddressFor(address).getOrElse(provider.getDefaultAddress))
}
}*/
ActorSystem originalSystem = null;
if (@ref is ActorRefWithCell)
{
originalSystem = @ref.AsInstanceOf<ActorRefWithCell>().Underlying.System;
if (CurrentTransportInformation == null)
{
return @ref.Path.ToSerializationFormat();
}
return @ref.Path.ToStringWithAddress(CurrentTransportInformation.Address);
}
return @ref.Path.ToSerializationFormat();
}
示例7: AwaitStarted
void AwaitStarted(IActorRef actorRef)
{
AwaitCondition(() =>
{
if (actorRef is RepointableActorRef)
return actorRef.AsInstanceOf<RepointableActorRef>().IsStarted;
return true;
}, TimeSpan.FromSeconds(1), TimeSpan.FromMilliseconds(10));
}