Class SingleThreadDispatcher.
상속: MessageDispatcher
예제 #1
0
        /// <summary>
        ///     Froms the configuration.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns>MessageDispatcher.</returns>
        public MessageDispatcher FromConfig(string path)
        {
            //TODO: this should not exist, it is only here because we dont serialize dispathcer when doing remote deploy..
            if (string.IsNullOrEmpty(path))
            {
                var disp = new ThreadPoolDispatcher
                {
                    Throughput = 100
                };
                return(disp);
            }

            Config config     = system.Settings.Config.GetConfig(path);
            string type       = config.GetString("type");
            int    throughput = config.GetInt("throughput");
            //shutdown-timeout
            //throughput-deadline-time
            //attempt-teamwork
            //mailbox-requirement

            MessageDispatcher dispatcher;

            switch (type)
            {
            case "Dispatcher":
                dispatcher = new ThreadPoolDispatcher();
                break;

            case "PinnedDispatcher":
                dispatcher = new SingleThreadDispatcher();
                break;

            case "SynchronizedDispatcher":
                dispatcher = new CurrentSynchronizationContextDispatcher();
                break;

            default:
                Type dispatcherType = Type.GetType(type);
                if (dispatcherType == null)
                {
                    throw new NotSupportedException("Could not resolve dispatcher type " + type);
                }
                dispatcher = (MessageDispatcher)Activator.CreateInstance(dispatcherType);
                break;
            }

            dispatcher.Throughput = throughput;
            //  dispatcher.ThroughputDeadlineTime

            return(dispatcher);
        }
예제 #2
0
        /// <summary>
        ///     Froms the configuration.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns>MessageDispatcher.</returns>
        public MessageDispatcher FromConfig(string path)
        {
            //TODO: this should not exist, it is only here because we dont serialize dispathcer when doing remote deploy..
            if (string.IsNullOrEmpty(path))
            {
                var disp = new ThreadPoolDispatcher
                {
                    Throughput = 100
                };
                return disp;
            }

            Config config = _system.Settings.Config.GetConfig(path);
            string type = config.GetString("type");
            int throughput = config.GetInt("throughput");
            //shutdown-timeout
            //throughput-deadline-time
            //attempt-teamwork
            //mailbox-requirement

            MessageDispatcher dispatcher;
            switch (type)
            {
                case "Dispatcher":
                    dispatcher = new ThreadPoolDispatcher();
                    break;
                case "PinnedDispatcher":
                    dispatcher = new SingleThreadDispatcher();
                    break;
                case "SynchronizedDispatcher":
                    dispatcher = new CurrentSynchronizationContextDispatcher();
                    break;
                default:
                    Type dispatcherType = Type.GetType(type);
                    if (dispatcherType == null)
                    {
                        throw new NotSupportedException("Could not resolve dispatcher type " + type);
                    }
                    dispatcher = (MessageDispatcher) Activator.CreateInstance(dispatcherType);
                    break;
            }

            dispatcher.Throughput = throughput;
            //  dispatcher.ThroughputDeadlineTime 

            return dispatcher;
        }
예제 #3
0
 public PinnedDispatcherConfigurator(Config config, IDispatcherPrerequisites prerequisites) : base(config, prerequisites)
 {
     _dispatcher = new SingleThreadDispatcher(this);
 }