return outgoing.TryReceiveAll (out items);
}
+ /// <summary>
+ /// Verifies whether <see cref="GroupingDataflowBlockOptions.MaxNumberOfGroups"/>
+ /// has been reached. If it did, <see cref="Complete"/>s the block.
+ /// </summary>
void VerifyMaxNumberOfGroups ()
{
if (dataflowBlockOptions.MaxNumberOfGroups == -1)
Complete ();
}
+ /// <summary>
+ /// Returns whether a new item can be accepted, and increments a counter if it can.
+ /// Only makes sense when <see cref="GroupingDataflowBlockOptions.MaxNumberOfGroups"/>
+ /// is not unbounded.
+ /// </summary>
bool TryAdd ()
{
bool lockTaken = false;
}
}
+ /// <summary>
+ /// Decides whether to create a new batch or not.
+ /// </summary>
+ /// <param name="addedItems">
+ /// Number of newly added items. Used only with greedy processing.
+ /// </param>
void BatchProcess (int addedItems = 0)
{
if (dataflowBlockOptions.Greedy) {
}
}
+ /// <summary>
+ /// Returns whether non-greedy creation of a batch should be started.
+ /// </summary>
bool ShouldProcessNonGreedy ()
{
// do we have enough items waiting and would the new batch fit?
|| outgoing.Count + batchSize <= dataflowBlockOptions.BoundedCapacity);
}
+ /// <summary>
+ /// Creates a batch of the given size and adds the result to the output queue.
+ /// </summary>
void MakeBatch (int size)
{
T[] batch = new T[size];
VerifyMaxNumberOfGroups ();
}
+ /// <summary>
+ /// Starts non-greedy creation of batches, if one doesn't already run.
+ /// </summary>
+ /// <param name="manuallyTriggered">Whether the batch was triggered by <see cref="TriggerBatch"/>.</param>
void EnsureNonGreedyProcessing (bool manuallyTriggered)
{
if (nonGreedyProcessing.TrySet ())
dataflowBlockOptions.TaskScheduler);
}
+ /// <summary>
+ /// Creates batches in non-greedy mode,
+ /// making sure the whole batch is available by using reservations.
+ /// </summary>
+ /// <param name="manuallyTriggered">Whether the batch was triggered by <see cref="TriggerBatch"/>.</param>
void NonGreedyProcess (bool manuallyTriggered)
{
bool first = true;