Example #1
0
 /// <summary>
 /// Creates a new instance of the <see cref="ConcurrencyLimiter"/> class.
 /// </summary>
 /// <param name="synchronizedOperationFactory">Factory function for creating the synchronized operations to be used for processing tasks.</param>
 /// <param name="maximumConcurrencyLevel">The initial value for <see cref="MaximumConcurrencyLevel"/>.</param>
 public ConcurrencyLimiter(SynchronizedOperationFactory synchronizedOperationFactory, int maximumConcurrencyLevel)
 {
     SynchronizedOperationFactory = synchronizedOperationFactory;
     TaskProcessors = new ConcurrentBag <ISynchronizedOperation>();
     Queue          = new ConcurrentQueue <Task>();
     SetMaximumConcurrencyLevel(maximumConcurrencyLevel);
 }
Example #2
0
 /// <summary>
 /// Creates a new instance of the <see cref="PriorityStrand"/> class.
 /// </summary>
 /// <param name="synchronizedOperationFactory">Factory function for creating the synchronized operation to be used for processing tasks.</param>
 /// <param name="priorityLevels">The number of priority levels to be preallocated by the priority queue.</param>
 public PriorityStrand(SynchronizedOperationFactory synchronizedOperationFactory, int priorityLevels)
 {
     SynchronizedOperation = synchronizedOperationFactory(Execute);
     Queue = new PriorityQueue <QueuedTask>(priorityLevels);
 }
Example #3
0
 /// <summary>
 /// Creates a new instance of the <see cref="PriorityStrand"/> class.
 /// </summary>
 /// <param name="synchronizedOperationFactory">Factory function for creating the synchronized operation to be used for processing tasks.</param>
 public PriorityStrand(SynchronizedOperationFactory synchronizedOperationFactory) : this(synchronizedOperationFactory, 1)
 {
 }
Example #4
0
 /// <summary>
 /// Creates a new instance of the <see cref="ConcurrencyLimiter"/> class with a
 /// maximum concurrency level equal to the number of processors on the current machine.
 /// </summary>
 /// <param name="synchronizedOperationFactory">Factory function for creating the synchronized operations to be used for processing tasks.</param>
 public ConcurrencyLimiter(SynchronizedOperationFactory synchronizedOperationFactory) : this(synchronizedOperationFactory, Environment.ProcessorCount)
 {
 }
Example #5
0
 /// <summary>
 /// Creates a new instance of the <see cref="Strand"/> class.
 /// </summary>
 /// <param name="synchronizedOperationFactory">Factory function for creating the synchronized operation to be used for processing tasks.</param>
 public Strand(SynchronizedOperationFactory synchronizedOperationFactory)
 {
     SynchronizedOperation = synchronizedOperationFactory(Execute);
     Queue = new ConcurrentQueue <Task>();
 }