Base class used for hooking new MessageDispatcher types into Dispatchers
示例#1
0
 public DispatcherConfigurator(MessageDispatcherConfigurator configurator, string id, int throughput, long?throughputDeadlineTime)
     : base(configurator.Config, configurator.Prerequisites)
 {
     _configurator          = configurator;
     ThroughputDeadlineTime = throughputDeadlineTime;
     Id         = id;
     Throughput = throughput;
 }
示例#2
0
 /// <summary>
 /// Used to create a default <see cref="Dispatcher"/>
 /// </summary>
 /// <param name="configurator">The configurator used.</param>
 /// <param name="id">The id of this dispatcher.</param>
 /// <param name="throughput">The throughput of this dispatcher.</param>
 /// <param name="throughputDeadlineTime">The deadline for completing N (where N = throughput) operations on the mailbox..</param>
 /// <param name="executorServiceFactory">The factory for producing the executor who will do the work.</param>
 /// <param name="shutdownTimeout">The graceful stop timeout period.</param>
 public Dispatcher(MessageDispatcherConfigurator configurator, string id, int throughput, long? throughputDeadlineTime,
     ExecutorServiceFactory executorServiceFactory, TimeSpan shutdownTimeout) : base(configurator)
 {
     _executorService = new LazyExecutorServiceDelegate(id, executorServiceFactory);
     Id = id;
     Throughput = throughput;
     ThroughputDeadlineTime = throughputDeadlineTime;
     ShutdownTimeout = shutdownTimeout;
 }
示例#3
0
 /// <summary>
 /// Used to create a default <see cref="Dispatcher"/>
 /// </summary>
 /// <param name="configurator">The configurator used.</param>
 /// <param name="id">The id of this dispatcher.</param>
 /// <param name="throughput">The throughput of this dispatcher.</param>
 /// <param name="throughputDeadlineTime">The deadline for completing N (where N = throughput) operations on the mailbox..</param>
 /// <param name="executorServiceFactory">The factory for producing the executor who will do the work.</param>
 /// <param name="shutdownTimeout">The graceful stop timeout period.</param>
 public Dispatcher(MessageDispatcherConfigurator configurator, string id, int throughput, long?throughputDeadlineTime,
                   ExecutorServiceFactory executorServiceFactory, TimeSpan shutdownTimeout) : base(configurator)
 {
     _executorService = new LazyExecutorServiceDelegate(id, executorServiceFactory);
     Id                     = id;
     Throughput             = throughput;
     ThroughputDeadlineTime = throughputDeadlineTime;
     ShutdownTimeout        = shutdownTimeout;
 }
 public CurrentSynchronizationContextDispatcher(MessageDispatcherConfigurator configurator, string id, int throughput, long? throughputDeadlineTime, ExecutorServiceFactory executorServiceFactory, TimeSpan shutdownTimeout) 
     : base(configurator, id, throughput, throughputDeadlineTime, executorServiceFactory, shutdownTimeout)
 {
     /*
      * Critical: in order for the CurrentSynchronizationContextExecutor to function properly, it can't be lazily 
      * initialized like all of the others. It has to be executed right away.
      */
     ExecuteTask(new NoTask());
 }
示例#5
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="configurator">TBD</param>
 /// <param name="id">TBD</param>
 /// <param name="throughput">TBD</param>
 /// <param name="throughputDeadlineTime">TBD</param>
 /// <param name="executorServiceFactory">TBD</param>
 /// <param name="shutdownTimeout">TBD</param>
 public CurrentSynchronizationContextDispatcher(MessageDispatcherConfigurator configurator, string id, int throughput, long?throughputDeadlineTime, ExecutorServiceFactory executorServiceFactory, TimeSpan shutdownTimeout)
     : base(configurator, id, throughput, throughputDeadlineTime, executorServiceFactory, shutdownTimeout)
 {
     /*
      * Critical: in order for the CurrentSynchronizationContextExecutor to function properly, it can't be lazily
      * initialized like all of the others. It has to be executed right away.
      */
     ExecuteTask(new NoTask());
 }
示例#6
0
 public void Setup(BenchmarkContext context)
 {
     _configurator = Configurator();
     _dispatcher = _configurator.Dispatcher();
     _dispatcherCounter = context.GetCounter(DispatcherCounterName);
     ScheduledWork = () =>
     {
         _dispatcherCounter.Increment();
         if (Interlocked.Increment(ref _messagesSeen) == ScheduleCount)
         {
             EventBlock.Set();
         }
     };
     Warmup(_dispatcher);
 }
示例#7
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="SingleThreadDispatcher" /> class.
        /// </summary>
        public SingleThreadDispatcher(MessageDispatcherConfigurator configurator)
            : base(configurator)
        {
            var thread = new Thread(_ =>
            {
                foreach (var next in queue.GetConsumingEnumerable())
                {
                    next();
                    if (!running)
                    {
                        return;
                    }
                }
            });

            thread.Start(); //thread won't start automatically without this
        }
 public void Setup(BenchmarkContext context)
 {
     Sys = ActorSystem.Create("Sys");
     Prereqs = new DefaultDispatcherPrerequisites(Sys.EventStream, Sys.Scheduler, Sys.Settings, Sys.Mailboxes);
     _configurator = Configurator();
     _dispatcher = _configurator.Dispatcher();
     _dispatcherCounter = context.GetCounter(DispatcherCounterName);
     ScheduledWork = () =>
     {
         _dispatcherCounter.Increment();
         if (Interlocked.Increment(ref _messagesSeen) == ScheduleCount)
         {
             EventBlock.Set();
         }
     };
     Warmup(_dispatcher);
 }
示例#9
0
 /// <summary>
 /// Takes a <see cref="MessageDispatcherConfigurator"/>
 /// </summary>
 public ThreadPoolDispatcher(MessageDispatcherConfigurator configurator) : base(configurator)
 {
 }
示例#10
0
 /// <summary>
 /// Takes a <see cref="MessageDispatcherConfigurator"/>
 /// </summary>
 public TaskDispatcher(MessageDispatcherConfigurator configurator) : base(configurator)
 {
 }
示例#11
0
 public PinnedDispatcher(MessageDispatcherConfigurator configurator, 
     string id, int throughput, long? throughputDeadlineTime, 
     ExecutorServiceFactory executorServiceFactory, 
     TimeSpan shutdownTimeout) : base(configurator, id, throughput, throughputDeadlineTime, executorServiceFactory, shutdownTimeout)
 {
 }
示例#12
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MessageDispatcher" /> class.
 /// </summary>
 protected MessageDispatcher(MessageDispatcherConfigurator configurator)
 {
     Configurator = configurator;
     Throughput = DefaultThroughput;
 }
示例#13
0
 /// <summary>
 /// Register a <see cref="MessageDispatcherConfigurator"/> that will be used by <see cref="Lookup"/>
 /// and <see cref="HasDispatcher"/> instead of looking up the configurator from the system
 /// configuration.
 ///
 /// This enables dynamic addition of dispatchers.
 ///
 /// <remarks>
 /// A <see cref="MessageDispatcherConfigurator"/> for a certain id can only be registered once,
 /// i.e. it can not be replaced. It is safe to call this method multiple times, but only the
 /// first registration will be used.
 /// </remarks>
 /// </summary>
 /// <returns>This method returns <c>true</c> if the specified configurator was successfully registered.</returns>
 public bool RegisterConfigurator(string id, MessageDispatcherConfigurator configurator)
 {
     return(_dispatcherConfigurators.TryAdd(id, configurator));
 }
 public CallingThreadDispatcher(MessageDispatcherConfigurator configurator) : base(configurator)
 {
 }
 internal SingleThreadDispatcher(MessageDispatcherConfigurator configurator, DedicatedThreadPoolSettings settings)
     : base(configurator)
 {
     _dedicatedThreadPool = new DedicatedThreadPool(settings);
 }
示例#16
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MessageDispatcher" /> class.
 /// </summary>
 protected MessageDispatcher(MessageDispatcherConfigurator configurator)
 {
     Configurator = configurator;
     Throughput   = DefaultThroughput;
 }
示例#17
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="configurator">TBD</param>
 /// <param name="id">TBD</param>
 /// <param name="throughput">TBD</param>
 /// <param name="throughputDeadlineTime">TBD</param>
 /// <param name="executorServiceFactory">TBD</param>
 /// <param name="shutdownTimeout">TBD</param>
 public PinnedDispatcher(MessageDispatcherConfigurator configurator,
                         string id, int throughput, long?throughputDeadlineTime,
                         ExecutorServiceFactory executorServiceFactory,
                         TimeSpan shutdownTimeout) : base(configurator, id, throughput, throughputDeadlineTime, executorServiceFactory, shutdownTimeout)
 {
 }
示例#18
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MessageDispatcher" /> class.
 /// </summary>
 protected MessageDispatcher(MessageDispatcherConfigurator configurator)
 {
     Configurator = configurator;
     Throughput = DefaultThroughput;
     _shutdownAction = new ShutdownAction(this);
 }
示例#19
0
 /// <summary>
 /// Takes a <see cref="MessageDispatcherConfigurator"/>
 /// </summary>
 public TaskDispatcher(MessageDispatcherConfigurator configurator) : base(configurator)
 {
 }
示例#20
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MessageDispatcher" /> class.
 /// </summary>
 /// <param name="configurator">TBD</param>
 protected MessageDispatcher(MessageDispatcherConfigurator configurator)
 {
     Configurator    = configurator;
     Throughput      = DefaultThroughput;
     _shutdownAction = new ShutdownAction(this);
 }
示例#21
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="CurrentSynchronizationContextDispatcher" /> class.
 /// </summary>
 public CurrentSynchronizationContextDispatcher(MessageDispatcherConfigurator configurator)
     : base(configurator)
 {
     _scheduler = TaskScheduler.FromCurrentSynchronizationContext();
 }
示例#22
0
 /// <summary>
 /// Register a <see cref="MessageDispatcherConfigurator"/> that will be used by <see cref="Lookup"/>
 /// and <see cref="HasDispatcher"/> instead of looking up the configurator from the system
 /// configuration.
 /// 
 /// This enables dynamic addition of dispatchers.
 /// 
 /// <remarks>
 /// A <see cref="MessageDispatcherConfigurator"/> for a certain id can only be registered once,
 /// i.e. it can not be replaced. It is safe to call this method multiple times, but only the
 /// first registration will be used.
 /// </remarks>
 /// </summary>
 /// <returns>This method returns <c>true</c> if the specified configurator was successfully registered.</returns>
 public bool RegisterConfigurator(string id, MessageDispatcherConfigurator configurator)
 {
     return _dispatcherConfigurators.TryAdd(id, configurator);
 }
示例#23
0
 internal ForkJoinDispatcher(MessageDispatcherConfigurator configurator, DedicatedThreadPoolSettings settings) : base(configurator)
 {
     _dedicatedThreadPool = new DedicatedThreadPool(settings);
 }