/// <summary> /// Initializes a new instance of the <see cref="TaskSchedulerPollingJob"/> class. /// </summary> /// <param name="configProvider">The configuration provider to retrieve configuration.</param> /// <param name="repository">The repository to use.</param> /// <param name="dateTimeProvider">The date time provider to use.</param> /// <param name="facade">The task processor facade to use to submit tasks.</param> public TaskSchedulerPollingJob(ITaskProcessorConfigurationProvider configProvider, ITaskProcessorRepository repository, IDateTimeProvider dateTimeProvider, ITaskProcessorFacade facade) { if (configProvider == null) { throw new ArgumentNullException(nameof(configProvider)); } if (repository == null) { throw new ArgumentNullException(nameof(repository)); } if (dateTimeProvider == null) { throw new ArgumentNullException(nameof(dateTimeProvider)); } if (facade == null) { throw new ArgumentNullException(nameof(facade)); } this.configuration = configProvider.GetTaskSchedulerConfiguration(); this.repository = repository; this.dateTimeProvider = dateTimeProvider; this.facade = facade; this.repository.ScheduledTasks.Added += this.OnScheduledTaskAdded; this.repository.ScheduledTasks.Updated += this.OnScheduledTaskUpdated; this.repository.ScheduledTasks.Deleted += this.OnScheduledTaskDeleted; }
public void GetScheduledTaskInvalid() { ITaskSchedulerConfiguration configuration = AppConfigConfigurationUnitTests.GetTaskSchedulerConfiguration("TaskScheduler"); if (configuration.ScheduledTasks[typeof(object)] == null) { } }
public void GetScheduledTaskNull() { ITaskSchedulerConfiguration configuration = AppConfigConfigurationUnitTests.GetTaskSchedulerConfiguration("TaskScheduler"); if (configuration.ScheduledTasks[null] == null) { } }
/// <summary> /// Initializes a new instance of the <see cref="TaskSchedulerMultiple"/> class. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="waitForFreeThread">The wait for free thread.</param> /// <param name="metrics">The metrics.</param> /// <param name="jobCounter">The job counter.</param> /// <param name="multipleConfiguration">The multiple configuration.</param> public TaskSchedulerMultiple(ITaskSchedulerConfiguration configuration, IWaitForEventOrCancelThreadPool waitForFreeThread, IMetrics metrics, ITaskSchedulerJobCountSync jobCounter, TaskSchedulerMultipleConfiguration multipleConfiguration) : base(configuration, waitForFreeThread, metrics) { Guard.NotNull(() => jobCounter, jobCounter); Guard.NotNull(() => multipleConfiguration, multipleConfiguration); _jobCount = jobCounter; MultipleConfiguration = multipleConfiguration; }
/// <summary> /// Initializes a new instance of the <see cref="SmartThreadPoolTaskScheduler"/> class. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="waitForFreeThread">The wait for free thread.</param> /// <param name="metrics">the metrics factory</param> public SmartThreadPoolTaskScheduler(ITaskSchedulerConfiguration configuration, IWaitForEventOrCancelThreadPool waitForFreeThread, IMetrics metrics) { Guard.NotNull(() => configuration, configuration); Guard.NotNull(() => waitForFreeThread, waitForFreeThread); Guard.NotNull(() => metrics, metrics); _configuration = configuration; _waitForFreeThread = waitForFreeThread; _metrics = metrics; _groups = new ConcurrentDictionary<IWorkGroup, WorkGroupWithItem>(); _clients = new ConcurrentDictionary<int, int>(); var name = GetType().Name; _taskCounter = metrics.Counter($"{name}.TaskCounter", Units.Items); _clientCounter = metrics.Counter($"{name}.ClientCounter", Units.Items); }
/// <summary> /// Initializes a new instance of the <see cref="SmartThreadPoolTaskScheduler"/> class. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="waitForFreeThread">The wait for free thread.</param> /// <param name="metrics">the metrics factory</param> public SmartThreadPoolTaskScheduler(ITaskSchedulerConfiguration configuration, IWaitForEventOrCancelThreadPool waitForFreeThread, IMetrics metrics) { Guard.NotNull(() => configuration, configuration); Guard.NotNull(() => waitForFreeThread, waitForFreeThread); Guard.NotNull(() => metrics, metrics); _configuration = configuration; _waitForFreeThread = waitForFreeThread; _metrics = metrics; _groups = new ConcurrentDictionary <IWorkGroup, WorkGroupWithItem>(); _clients = new ConcurrentDictionary <int, int>(); var name = GetType().Name; _taskCounter = metrics.Counter($"{name}.TaskCounter", Units.Items); _clientCounter = metrics.Counter($"{name}.ClientCounter", Units.Items); }
public void TaskSchedulerWaitTrue() { ITaskSchedulerConfiguration configuration = AppConfigConfigurationUnitTests.GetTaskSchedulerConfiguration("WaitTrue"); Assert.IsTrue(configuration.ScheduledTasks[typeof(FakeScheduledTask)].WaitForPreviousSubmittedTaskToComplete); }