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


C# IActorRef.AsInstanceOf方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:7,代码来源:Router.cs

示例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);
     }
 }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:7,代码来源:BoundedMessageQueue.cs

示例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
        }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:20,代码来源:ReceiveOnlyBenchmark.cs

示例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>());
        }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:14,代码来源:MailboxBenchmarks.cs

示例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));
        }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:15,代码来源:ActorsLeakSpec.cs

示例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();
        }
开发者ID:MaciekLesiczka,项目名称:akka.net,代码行数:35,代码来源:Serialization.cs

示例7: AwaitStarted

 void AwaitStarted(IActorRef actorRef)
 {
     AwaitCondition(() =>
     {
         if (actorRef is RepointableActorRef)
             return actorRef.AsInstanceOf<RepointableActorRef>().IsStarted;
         return true;
     }, TimeSpan.FromSeconds(1), TimeSpan.FromMilliseconds(10));
 }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:9,代码来源:ActorModelSpec.cs


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