Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Linq / Parallel / QueryOperators / Inlined / InlinedAggregationOperatorEnumerator.cs / 1305376 / InlinedAggregationOperatorEnumerator.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
//
// InlinedAggregationOperatorEnumerator.cs
//
// [....]
//
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
using System.Threading;
namespace System.Linq.Parallel
{
//----------------------------------------------------------------------------------------
// Inlined aggregate operators for finding the min/max values for primitives (int, long, float,
// double, decimal). Versions are also offered for the nullable primitives (int?, long?, float?,
// double?, decimal?), which differ slightly in behavior: they return a null value for empty
// streams, whereas the ordinary primitive versions throw.
//
//---------------------------------------------------------------------------------------
// Inlined average operators for primitives (int, long, float, double, decimal), and the
// nullable variants. The difference between the nromal and nullable variety is that
// nulls are skipped in tallying the count and sum for the average.
//
///
/// A class with some shared implementation between all aggregation enumerators.
///
///
internal abstract class InlinedAggregationOperatorEnumerator : QueryOperatorEnumerator
{
private int m_partitionIndex; // This partition's unique index.
protected CancellationToken m_cancellationToken;
//---------------------------------------------------------------------------------------
// Instantiates a new aggregation operator.
//
internal InlinedAggregationOperatorEnumerator(int partitionIndex, CancellationToken cancellationToken)
{
m_partitionIndex = partitionIndex;
m_cancellationToken = cancellationToken;
}
//---------------------------------------------------------------------------------------
// Tallies up the sum of the underlying data source, walking the entire thing the first
// time MoveNext is called on this object. There is a boilerplate variant used by callers,
// and then one that is used for extensibility by subclasses.
//
internal sealed override bool MoveNext(ref TIntermediate currentElement, ref int currentKey)
{
if (MoveNextCore(ref currentElement))
{
// A reduction's "index" is the same as its partition number.
currentKey = m_partitionIndex;
return true;
}
return false;
}
protected abstract bool MoveNextCore(ref TIntermediate currentElement);
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
//
// InlinedAggregationOperatorEnumerator.cs
//
// [....]
//
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
using System.Threading;
namespace System.Linq.Parallel
{
//----------------------------------------------------------------------------------------
// Inlined aggregate operators for finding the min/max values for primitives (int, long, float,
// double, decimal). Versions are also offered for the nullable primitives (int?, long?, float?,
// double?, decimal?), which differ slightly in behavior: they return a null value for empty
// streams, whereas the ordinary primitive versions throw.
//
//---------------------------------------------------------------------------------------
// Inlined average operators for primitives (int, long, float, double, decimal), and the
// nullable variants. The difference between the nromal and nullable variety is that
// nulls are skipped in tallying the count and sum for the average.
//
///
/// A class with some shared implementation between all aggregation enumerators.
///
///
internal abstract class InlinedAggregationOperatorEnumerator : QueryOperatorEnumerator
{
private int m_partitionIndex; // This partition's unique index.
protected CancellationToken m_cancellationToken;
//---------------------------------------------------------------------------------------
// Instantiates a new aggregation operator.
//
internal InlinedAggregationOperatorEnumerator(int partitionIndex, CancellationToken cancellationToken)
{
m_partitionIndex = partitionIndex;
m_cancellationToken = cancellationToken;
}
//---------------------------------------------------------------------------------------
// Tallies up the sum of the underlying data source, walking the entire thing the first
// time MoveNext is called on this object. There is a boilerplate variant used by callers,
// and then one that is used for extensibility by subclasses.
//
internal sealed override bool MoveNext(ref TIntermediate currentElement, ref int currentKey)
{
if (MoveNextCore(ref currentElement))
{
// A reduction's "index" is the same as its partition number.
currentKey = m_partitionIndex;
return true;
}
return false;
}
protected abstract bool MoveNextCore(ref TIntermediate currentElement);
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- NeutralResourcesLanguageAttribute.cs
- FacetDescription.cs
- TextParaLineResult.cs
- HtmlTitle.cs
- SchemaNotation.cs
- FontUnit.cs
- RemoteWebConfigurationHostServer.cs
- CompositeActivityTypeDescriptorProvider.cs
- SoapIncludeAttribute.cs
- LocatorBase.cs
- HtmlEncodedRawTextWriter.cs
- SR.cs
- Trace.cs
- ImageBrush.cs
- DataRelationCollection.cs
- SecurityRuntime.cs
- Win32Exception.cs
- ViewGenResults.cs
- SettingsContext.cs
- CurrencyWrapper.cs
- Int32CollectionConverter.cs
- SpeechSeg.cs
- FilterableAttribute.cs
- SocketSettings.cs
- __Filters.cs
- COM2Enum.cs
- HWStack.cs
- RuntimeHelpers.cs
- InvokePattern.cs
- __Filters.cs
- RubberbandSelector.cs
- SchemaCompiler.cs
- Image.cs
- StatusStrip.cs
- AxParameterData.cs
- ValidationManager.cs
- SynchronizedDispatch.cs
- IssuedTokenParametersEndpointAddressElement.cs
- SettingsBindableAttribute.cs
- StateChangeEvent.cs
- OrderByExpression.cs
- Pkcs9Attribute.cs
- unitconverter.cs
- DES.cs
- KnownIds.cs
- SuppressMessageAttribute.cs
- Calendar.cs
- SqlXml.cs
- CrossContextChannel.cs
- SessionSwitchEventArgs.cs
- HtmlImageAdapter.cs
- GPPOINT.cs
- SystemTcpConnection.cs
- BulletDecorator.cs
- EncryptRequest.cs
- OrderedEnumerableRowCollection.cs
- ColorTransform.cs
- LinkDescriptor.cs
- IndexedWhereQueryOperator.cs
- _Win32.cs
- PathFigure.cs
- UrlParameterWriter.cs
- ColumnResizeUndoUnit.cs
- ClassHandlersStore.cs
- SponsorHelper.cs
- DataGridTextBoxColumn.cs
- ConfigurationManagerHelper.cs
- KeyConstraint.cs
- MimeParameters.cs
- EmbossBitmapEffect.cs
- SamlAssertion.cs
- SrgsSemanticInterpretationTag.cs
- WebBrowser.cs
- HttpClientCertificate.cs
- IriParsingElement.cs
- OleDbPermission.cs
- OpCopier.cs
- HwndSubclass.cs
- QuaternionAnimation.cs
- SqlBuilder.cs
- Processor.cs
- TargetException.cs
- TableCell.cs
- TextBoxBaseDesigner.cs
- InvokeHandlers.cs
- SettingsProviderCollection.cs
- ConstraintCollection.cs
- Accessible.cs
- COM2Properties.cs
- LocalizationCodeDomSerializer.cs
- ProfilePropertyMetadata.cs
- XmlValidatingReaderImpl.cs
- CaseInsensitiveHashCodeProvider.cs
- Int32Rect.cs
- ToolStripTextBox.cs
- CharEnumerator.cs
- COMException.cs
- ListenerElementsCollection.cs
- PublisherMembershipCondition.cs
- PointConverter.cs