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


C# Props.WithDispatcher方法代码示例

本文整理汇总了C#中Props.WithDispatcher方法的典型用法代码示例。如果您正苦于以下问题:C# Props.WithDispatcher方法的具体用法?C# Props.WithDispatcher怎么用?C# Props.WithDispatcher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Props的用法示例。


在下文中一共展示了Props.WithDispatcher方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ActorOf

        public override InternalActorRef ActorOf(ActorSystem system, Props props, InternalActorRef supervisor,
            ActorPath path)
        {
            Mailbox mailbox = System.Mailboxes.FromConfig(props.Mailbox);

            Deploy configDeploy = System.Provider.Deployer.Lookup(path);
            var deploy = configDeploy ?? props.Deploy ?? Deploy.None;
            if (deploy.Mailbox != null)
                props = props.WithMailbox(deploy.Mailbox);
            if (deploy.Dispatcher != null)
                props = props.WithDispatcher(deploy.Dispatcher);
            if (deploy.Scope is RemoteScope)
            {

            }

            //If this actor is a Router
            if (!(props.RouterConfig is NoRouter || props.RouterConfig == null))
            {
                //if no Router config value was specified, override with procedural input
                if (deploy.RouterConfig is NoRouter)
                {
                    deploy = deploy.WithRouterConfig(props.RouterConfig);
                }
            }
            props = props.WithDeploy(deploy);
            

            if (string.IsNullOrEmpty(props.Mailbox))
            {
                //   throw new NotSupportedException("Mailbox can not be configured as null or empty");
            }
            if (string.IsNullOrEmpty(props.Dispatcher))
            {
                //TODO: fix this..
                //    throw new NotSupportedException("Dispatcher can not be configured as null or empty");
            }


            if (props.Deploy != null && props.Deploy.Scope is RemoteScope)
            {
                return RemoteActorOf(system, props, supervisor, path, mailbox);
            }
            return LocalActorOf(system, props, supervisor, path, mailbox);
        }
开发者ID:Badmoonz,项目名称:akka.net,代码行数:45,代码来源:RemoteActorRefProvider.cs

示例2: ActorOf

        /// <summary>
        ///     Actors the of.
        /// </summary>
        /// <param name="system">The system.</param>
        /// <param name="props">The props.</param>
        /// <param name="supervisor">The supervisor.</param>
        /// <param name="path">The path.</param>
        /// <returns>InternalActorRef.</returns>
        public override InternalActorRef ActorOf(ActorSystem system, Props props, InternalActorRef supervisor,
            ActorPath path)
        {
            ActorCell cell = null;
            Mailbox mailbox = System.Mailboxes.FromConfig(props.Mailbox);

            Deploy configDeploy = System.Provider.Deployer.Lookup(path);
            var deploy = configDeploy ?? props.Deploy ?? Deploy.None;
            if (deploy.Mailbox != null)
                props = props.WithMailbox(deploy.Mailbox);
            if (deploy.Dispatcher != null)
                props = props.WithDispatcher(deploy.Dispatcher);
            if (deploy.Scope is RemoteScope)
            {

            }

            if (string.IsNullOrEmpty(props.Mailbox))
            {
                //   throw new NotSupportedException("Mailbox can not be configured as null or empty");
            }
            if (string.IsNullOrEmpty(props.Dispatcher))
            {
                //TODO: fix this..
                //    throw new NotSupportedException("Dispatcher can not be configured as null or empty");
            }


            if (props.Deploy != null && props.Deploy.Scope is RemoteScope)
            {
                throw new NotSupportedException("LocalActorRefProvider can not deploy remote");
            }

            if (props.RouterConfig is NoRouter || props.RouterConfig == null)
            {

                props = props.WithDeploy(deploy);
                cell = new ActorCell(system, supervisor, props, path, mailbox);

            }
            else
            {
                //if no Router config value was specified, override with procedural input
                if (deploy.RouterConfig is NoRouter) 
                {
                    deploy = deploy.WithRouterConfig(props.RouterConfig);
                }

                var routerProps =
                    Props.Create<RouterActor>()
                        .WithDeploy(deploy);

                var routeeProps = props.WithRouter(RouterConfig.NoRouter);

                cell = new RoutedActorCell(system, supervisor, routerProps, routeeProps, path, mailbox);

            }
            cell.NewActor();
            //   parentContext.Watch(cell.Self);
            return cell.Self;
        }
开发者ID:Badmoonz,项目名称:akka.net,代码行数:69,代码来源:ActorRefProvider.cs

示例3: ConfigureDispatcher

 public Props ConfigureDispatcher(Props props)
 {
     return String.IsNullOrEmpty(Dispatcher) ? props : props.WithDispatcher(Dispatcher);
 }
开发者ID:ClusterReply,项目名称:akka.net,代码行数:4,代码来源:RemoteSettings.cs

示例4: Create

        /// <summary>
        /// INTERNAL
        /// <remarks>Note! Part of internal API. Breaking changes may occur without notice. Use at own risk.</remarks>
        /// </summary>
        public static InternalTestActorRef Create(ActorSystem system, Props props, IActorRef supervisor = null, string name = null)
        {
            if(name == null)
                name = CreateUniqueName();

            if(supervisor == null)
            {
                var systemImpl = (ActorSystemImpl)system;
                supervisor = systemImpl.Guardian;
            }


            if(props.Deploy.Dispatcher == Deploy.NoDispatcherGiven)
            {
                props = props.WithDispatcher(CallingThreadDispatcher.Id);
            }

            var dispatcher = system.Dispatchers.Lookup(props.Deploy.Dispatcher);

            var supervisorLocal = supervisor as LocalActorRef;
            if(supervisorLocal != null)
            {
                supervisorLocal.Cell.ReserveChild(name);
            }
            else
            {
                var supervisorRep = supervisor as RepointableActorRef;
                if(supervisorRep != null)
                {
                    var repUnderlying = supervisorRep.Underlying;
                    if(repUnderlying is UnstartedCell)
                        throw new IllegalStateException("Cannot attach a TestActor to an unstarted top-level actor, ensure that it is started by sending a message and observing the reply");
                    var cellUnderlying = repUnderlying as ActorCell;
                    if(cellUnderlying != null)
                    {
                        cellUnderlying.ReserveChild(name);
                    }
                    else
                    {
                        system.Log.Error("Trying to attach child {0} to unknown type of supervisor cell {1}, this is not going to end well", name, repUnderlying.GetType());
                    }
                }
            }
            //TODO: Should be: Func<Mailbox> mailbox = () => system.Mailboxes.FromConfig(dispatcher.Configurator.Config);
            Func<Mailbox> mailbox = () => system.Mailboxes.CreateMailbox(props, null);
            var testActorRef = new InternalTestActorRef(system, props, dispatcher, mailbox, (IInternalActorRef)supervisor, supervisor.Path / name);

            // we need to start ourselves since the creation of an actor has been split into initialization and starting
            testActorRef.Underlying.Start();
            return testActorRef;
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:55,代码来源:InternalTestActorRef.cs

示例5: ActorOf

        public InternalActorRef ActorOf(ActorSystem system, Props props, InternalActorRef supervisor, ActorPath path, bool systemService, Deploy deploy, bool lookupDeploy, bool async)
        {
            //TODO: This does not match Akka's ActorOf at all

            Deploy configDeploy = _system.Provider.Deployer.Lookup(path);
            deploy = configDeploy ?? props.Deploy ?? Deploy.None;
            if(deploy.Mailbox != null)
                props = props.WithMailbox(deploy.Mailbox);
            if(deploy.Dispatcher != null)
                props = props.WithDispatcher(deploy.Dispatcher);
            if(deploy.Scope is RemoteScope)
            {

            }

            if(string.IsNullOrEmpty(props.Mailbox))
            {
                //   throw new NotSupportedException("Mailbox can not be configured as null or empty");
            }
            if(string.IsNullOrEmpty(props.Dispatcher))
            {
                //TODO: fix this..
                //    throw new NotSupportedException("Dispatcher can not be configured as null or empty");
            }


            //TODO: how should this be dealt with?
            //akka simply passes the "deploy" var from remote daemon to ActorOf
            //so it atleast seems like they ignore if remote scope is provided here.
            //leaving this for now since it does work

            //if (props.Deploy != null && props.Deploy.Scope is RemoteScope)
            //{
            //    throw new NotSupportedException("LocalActorRefProvider can not deploy remote");
            //}

            if(props.RouterConfig is NoRouter || props.RouterConfig == null)
            {

                props = props.WithDeploy(deploy);
                var dispatcher = system.Dispatchers.FromConfig(props.Dispatcher);
                var mailbox = _system.Mailboxes.FromConfig(props.Mailbox);
                    //TODO: Should be: system.mailboxes.getMailboxType(props2, dispatcher.configurator.config)

                if (async)
                {
                    var reActorRef=new RepointableActorRef(system, props, dispatcher, () => mailbox, supervisor, path);
                    reActorRef.Initialize(async:true);
                    return reActorRef;
                }
                return new LocalActorRef(system, props, dispatcher, () => mailbox, supervisor, path);
            }
            else
            {
                //if no Router config value was specified, override with procedural input
                if(deploy.RouterConfig is NoRouter)
                {
                    deploy = deploy.WithRouterConfig(props.RouterConfig);
                }
                var routerDispatcher = system.Dispatchers.FromConfig(props.RouterConfig.RouterDispatcher);
                var routerMailbox = _system.Mailboxes.FromConfig(props.Mailbox);
                    //TODO: Should be val routerMailbox = system.mailboxes.getMailboxType(routerProps, routerDispatcher.configurator.config)

                // routers use context.actorOf() to create the routees, which does not allow us to pass
                // these through, but obtain them here for early verification
                var routerProps = Props.Empty.WithDeploy(deploy);
                var routeeProps = props.WithRouter(RouterConfig.NoRouter);

                var routedActorRef = new RoutedActorRef(system, routerProps, routerDispatcher, () => routerMailbox, routeeProps,supervisor, path);
                routedActorRef.Initialize(async);
                return routedActorRef;
            }
        }
开发者ID:rmiller1971,项目名称:akka.net,代码行数:73,代码来源:ActorRefProvider.cs

示例6: EnrichWithPoolDispatcher

 private Props EnrichWithPoolDispatcher(Props routeeProps, IActorContext context)
 {
     //        if (usePoolDispatcher && routeeProps.dispatcher == Dispatchers.DefaultDispatcherId)
     //  routeeProps.withDispatcher("akka.actor.deployment." + context.self.path.elements.drop(1).mkString("/", "/", "")
     //    + ".pool-dispatcher")
     //else
     //  routeeProps
     if (UsePoolDispatcher && routeeProps.Dispatcher == Dispatchers.DefaultDispatcherId)
     {
         return
             routeeProps.WithDispatcher("akka.actor.deployment." + context.Self.Path.Elements.Drop(1).Join("/") +
                                        ".pool-dispatcher");
     }
     return routeeProps;
 }
开发者ID:jweimann,项目名称:akka.net,代码行数:15,代码来源:RouterConfig.cs

示例7: ActorOf

        public InternalActorRef ActorOf(ActorSystemImpl system, Props props, InternalActorRef supervisor, ActorPath path, bool systemService, Deploy deploy, bool lookupDeploy, bool async)
        {
            //TODO: This does not match Akka's ActorOf at all

            Deploy configDeploy = _system.Provider.Deployer.Lookup(path);
            deploy = configDeploy ?? props.Deploy ?? Deploy.None;
            if(deploy.Mailbox != Deploy.NoMailboxGiven)
                props = props.WithMailbox(deploy.Mailbox);
            if(deploy.Dispatcher != Deploy.NoDispatcherGiven)
                props = props.WithDispatcher(deploy.Dispatcher);

            //TODO: how should this be dealt with?
            //akka simply passes the "deploy" var from remote daemon to ActorOf
            //so it atleast seems like they ignore if remote scope is provided here.
            //leaving this for now since it does work

            if(props.RouterConfig.NoRouter())
            {
                return CreateNoRouter(system, props, supervisor, path, deploy, async);
            }

            return CreateWithRouter(system, props, supervisor, path, deploy, async);
        }
开发者ID:rodrigovidal,项目名称:akka.net,代码行数:23,代码来源:ActorRefProvider.cs


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