private DispatcherQueue(string name, Dispatcher dispatcher, TaskExecutionPolicy policy, int maximumQueueDepth, double schedulingRate) { if (dispatcher == null) { throw new ArgumentNullException("dispatcher"); } if ((policy == TaskExecutionPolicy.ConstrainQueueDepthDiscardTasks || policy == TaskExecutionPolicy.ConstrainQueueDepthThrottleExecution) && maximumQueueDepth <= 0) { throw new ArgumentOutOfRangeException("maximumQueueDepth"); } if ((policy == TaskExecutionPolicy.ConstrainSchedulingRateDiscardTasks || policy == TaskExecutionPolicy.ConstrainSchedulingRateThrottleExecution) && schedulingRate <= 0.0) { throw new ArgumentOutOfRangeException("schedulingRate"); } _dispatcher = dispatcher; _name = name; _policy = policy; _maximumQueueDepth = maximumQueueDepth; _maximumSchedulingRate = schedulingRate; dispatcher.AddQueue(name, this); if (policy != TaskExecutionPolicy.Unconstrained) { _watch = Stopwatch.StartNew(); } }
public IFuture Start(ISchedulable task, TaskExecutionPolicy executionPolicy = TaskExecutionPolicy.Default) { var future = new Future <object>(); Start(future, task, executionPolicy); return(future); }
public Future <T> Start <T> (ISchedulable <T> task, TaskExecutionPolicy executionPolicy = TaskExecutionPolicy.Default) { var future = new Future <T>(); Start(future, task, executionPolicy); return(future); }
public QueueProcessor(string queueName, int threadCount, TaskExecutionSchedulingPolicy taskExecutionSchedulingPolicy, Priority priority, double schedulingRate, int activateItems) { this.queueName = queueName; this.activateItems = activateItems; if (threadCount > 0) { ThreadPriority threadPriority = this.ConvertThreadPriority(priority); this.dispatcher = DispatcherFactory.CreateDispatcher(threadCount, threadPriority, this.queueName); } else { this.dispatcher = DispatcherFactory.DefaultDispatcher; } if (schedulingRate > 0.0) { TaskExecutionPolicy taskExecutionPolicy = this.ConvertTaskExecutionPolicy(taskExecutionSchedulingPolicy); this.dispatcherQueue = new DispatcherQueue(this.queueName, this.dispatcher, taskExecutionPolicy, schedulingRate); } else { this.dispatcherQueue = new DispatcherQueue(this.queueName, this.dispatcher); } this.upperBound = 0; this.port = new Port <T>(); this.teardownPort = new Port <EmptyValue>(); ReportableObjectDirectory.Add(this.queueName, this); }
private QueueProcessor(string queueName, int threadCount, TaskExecutionPolicy taskExecutionPolicy, ThreadPriority threadPriority, int maximumQueueDepth, double schedulingRate) { this.queueName = queueName; if (threadCount > 0) { this.dispatcher = DispatcherFactory.CreateDispatcher(threadCount, this.queueName); } else { this.dispatcher = DispatcherFactory.DefaultDispatcher; } if (maximumQueueDepth > 0) { this.dispatcherQueue = new DispatcherQueue(this.queueName, this.dispatcher, taskExecutionPolicy, maximumQueueDepth); } else { if (schedulingRate > 0.0) { this.dispatcherQueue = new DispatcherQueue(this.queueName, this.dispatcher, taskExecutionPolicy, schedulingRate); } else { this.dispatcherQueue = new DispatcherQueue(this.queueName, this.dispatcher); } } this.upperBound = maximumQueueDepth; this.port = new Port <T>(); this.teardownPort = new Port <EmptyValue>(); ReportableObjectDirectory.Add(this.queueName, this); }
public DispatcherQueue(string name, Dispatcher dispatcher, TaskExecutionPolicy policy, int maximumQueueDepth) : this(name, dispatcher, policy) { if (policy == TaskExecutionPolicy.ConstrainSchedulingRateDiscardTasks || policy == TaskExecutionPolicy.ConstrainSchedulingRateThrottleExecution) throw new ArgumentException ("schedulingRate"); if (maximumQueueDepth < 1 && policy != TaskExecutionPolicy.Unconstrained) throw new ArgumentException ("maximumQueueDepth"); MaximumQueueDepth = maximumQueueDepth; }
public StoreResult( IEnumerator <object> task, Expression <Func <T> > target, TaskExecutionPolicy executionPolicy = TaskExecutionPolicy.RunWhileFutureLives ) { _Task = task; _Thunk = new SchedulableGeneratorThunk(_Task); _ExecutionPolicy = executionPolicy; _Future = Future.New <T>(); _Future.Bind(target); _Future.RegisterOnComplete(Completed); }
public Future <T> Start <T> (System.Threading.Tasks.Task <T> task, TaskExecutionPolicy executionPolicy = TaskExecutionPolicy.RunAsBackgroundTask) { var future = task.GetFuture(); switch (executionPolicy) { case TaskExecutionPolicy.RunAsBackgroundTask: future.RegisterOnResolved(BackgroundTaskOnComplete); break; } return(future); }
public void Start(IFuture future, ISchedulable task, TaskExecutionPolicy executionPolicy) { task.Schedule(this, future); switch (executionPolicy) { case TaskExecutionPolicy.RunAsBackgroundTask: future.RegisterOnComplete(BackgroundTaskOnComplete); break; default: break; } }
public void Start <T> (Future <T> future, ISchedulable <T> task, TaskExecutionPolicy executionPolicy) { using (IsActive) task.Schedule(this, future); switch (executionPolicy) { case TaskExecutionPolicy.RunAsBackgroundTask: future.RegisterOnResolved(BackgroundTaskOnComplete); break; default: break; } }
public IFuture Start(IEnumerator <object> task, TaskExecutionPolicy executionPolicy = TaskExecutionPolicy.Default) { return(Start(new SchedulableGeneratorThunk(task), executionPolicy)); }
public DispatcherQueue(string name, Dispatcher dispatcher, TaskExecutionPolicy policy, int maximumQueueDepth) : this(name, dispatcher, policy, maximumQueueDepth, 0.0) { }
public DispatcherQueue(string name, Dispatcher dispatcher, TaskExecutionPolicy policy, double schedulingRate) : this(name, dispatcher, policy, 0, schedulingRate) { }
DispatcherQueue(string name, Dispatcher dispatcher, TaskExecutionPolicy policy) { if (name == null) throw new ArgumentNullException ("name"); if (dispatcher == null) throw new ArgumentNullException ("dispatcher"); this.dispatcher = dispatcher; Name = name; ThrottlingSleepInterval = new TimeSpan (0,0,0,0,10); Timescale = 1; Policy = policy; dispatcher.Register (this); }
public RunToCompletion(IEnumerator <object> task, TaskExecutionPolicy executionPolicy) : base(task, executionPolicy) { }
public Start(IEnumerator <object> task, TaskExecutionPolicy executionPolicy = TaskExecutionPolicy.RunWhileFutureLives) { _Task = task; _ExecutionPolicy = executionPolicy; _Future = null; }
public DispatcherQueue(string name, Dispatcher dispatcher, TaskExecutionPolicy policy, double schedulingRate) : this(name, dispatcher, policy) { if (policy == TaskExecutionPolicy.ConstrainQueueDepthDiscardTasks || policy == TaskExecutionPolicy.ConstrainQueueDepthThrottleExecution) throw new ArgumentException ("maximumQueueDepth"); if (schedulingRate < 1 && policy != TaskExecutionPolicy.Unconstrained) throw new ArgumentException ("schedulingRate"); MaximumSchedulingRate = schedulingRate; watch = Stopwatch.StartNew (); }