Used to create instances of the CurrentSynchronizationContextDispatcher. Always returns the a new instance.
Наследование: MessageDispatcherConfigurator
Пример #1
0
        private MessageDispatcherConfigurator ConfiguratorFrom(Config cfg)
        {
            if (cfg.IsNullOrEmpty())
            {
                throw ConfigurationException.NullOrEmptyConfig <MessageDispatcherConfigurator>();
            }

            if (!cfg.HasPath("id"))
            {
                throw new ConfigurationException($"Missing dispatcher `id` property in config: {cfg.Root}");
            }

            var id   = cfg.GetString("id", null);
            var type = cfg.GetString("type", null);


            MessageDispatcherConfigurator dispatcher;

            /*
             * Fallbacks are added here in order to preserve backwards compatibility with versions of AKka.NET prior to 1.1,
             * before the ExecutorService system was implemented
             */
            switch (type)
            {
            case "Dispatcher":
                dispatcher = new DispatcherConfigurator(cfg, Prerequisites);
                break;

            case "TaskDispatcher":
                dispatcher = new DispatcherConfigurator(TaskExecutorConfig.WithFallback(cfg), Prerequisites);
                break;

            case "PinnedDispatcher":
                dispatcher = new PinnedDispatcherConfigurator(cfg, Prerequisites);
                break;

            case "ForkJoinDispatcher":
                dispatcher = new DispatcherConfigurator(ForkJoinExecutorConfig.WithFallback(cfg), Prerequisites);
                break;

            case "SynchronizedDispatcher":
                dispatcher = new CurrentSynchronizationContextDispatcherConfigurator(cfg, Prerequisites);
                break;

            case null:
                throw new ConfigurationException($"Could not resolve dispatcher for path {id}. type is null");

            default:
                Type dispatcherType = Type.GetType(type);
                if (dispatcherType == null)
                {
                    throw new ConfigurationException($"Could not resolve dispatcher type {type} for path {id}");
                }
                dispatcher = (MessageDispatcherConfigurator)Activator.CreateInstance(dispatcherType, cfg, Prerequisites);
                break;
            }

            return(dispatcher);
        }
Пример #2
0
        private MessageDispatcherConfigurator ConfiguratorFrom(Config cfg)
        {
            if (!cfg.HasPath("id"))
            {
                throw new ConfigurationException(string.Format("Missing dispatcher `id` property in config: {0}", cfg.Root));
            }

            var id                     = cfg.GetString("id");
            var type                   = cfg.GetString("type");
            var throughput             = cfg.GetInt("throughput");
            var throughputDeadlineTime = cfg.GetTimeSpan("throughput-deadline-time").Ticks;


            MessageDispatcherConfigurator dispatcher;

            switch (type)
            {
            case "Dispatcher":
                dispatcher = new ThreadPoolDispatcherConfigurator(cfg, Prerequisites);
                break;

            case "TaskDispatcher":
                dispatcher = new TaskDispatcherConfigurator(cfg, Prerequisites);
                break;

            case "PinnedDispatcher":
                dispatcher = new PinnedDispatcherConfigurator(cfg, Prerequisites);
                break;

            case "ForkJoinDispatcher":
                dispatcher = new ForkJoinDispatcherConfigurator(cfg, Prerequisites);
                break;

            case "SynchronizedDispatcher":
                dispatcher = new CurrentSynchronizationContextDispatcherConfigurator(cfg, Prerequisites);
                break;

            case null:
                throw new ConfigurationException("Could not resolve dispatcher for path " + id + ". type is null");

            default:
                Type dispatcherType = Type.GetType(type);
                if (dispatcherType == null)
                {
                    throw new ConfigurationException("Could not resolve dispatcher type " + type + " for path " + id);
                }
                dispatcher = (MessageDispatcherConfigurator)Activator.CreateInstance(dispatcherType, cfg, Prerequisites);
                break;
            }

            return(new DispatcherConfigurator(dispatcher, id, throughput, throughputDeadlineTime));
        }
Пример #3
0
        private MessageDispatcherConfigurator ConfiguratorFrom(Config cfg)
        {
            if (!cfg.HasPath("id")) throw new ConfigurationException($"Missing dispatcher `id` property in config: {cfg.Root}");

            var id = cfg.GetString("id");
            var type = cfg.GetString("type");


            MessageDispatcherConfigurator dispatcher;
            /*
             * Fallbacks are added here in order to preserve backwards compatibility with versions of AKka.NET prior to 1.1,
             * before the ExecutorService system was implemented
             */
            switch (type)
            {
                case "Dispatcher":
                    dispatcher = new DispatcherConfigurator(cfg, Prerequisites);
                    break;
                case "TaskDispatcher":
                    dispatcher = new DispatcherConfigurator(TaskExecutorConfig.WithFallback(cfg), Prerequisites);
                    break;
                case "PinnedDispatcher":
                    dispatcher = new PinnedDispatcherConfigurator(cfg, Prerequisites);
                    break;
                case "ForkJoinDispatcher":
                    dispatcher = new DispatcherConfigurator(ForkJoinExecutorConfig.WithFallback(cfg), Prerequisites);
                    break;
                case "SynchronizedDispatcher":
                    dispatcher = new CurrentSynchronizationContextDispatcherConfigurator(cfg, Prerequisites);
                    break;
                case null:
                    throw new ConfigurationException($"Could not resolve dispatcher for path {id}. type is null");
                default:
                    Type dispatcherType = Type.GetType(type);
                    if (dispatcherType == null)
                    {
                        throw new ConfigurationException($"Could not resolve dispatcher type {type} for path {id}");
                    }
                    dispatcher = (MessageDispatcherConfigurator)Activator.CreateInstance(dispatcherType, cfg, Prerequisites);
                    break;
            }

            return dispatcher;
        }