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
- FixedSOMPageElement.cs
- KeyedCollection.cs
- StdValidatorsAndConverters.cs
- ConstraintCollection.cs
- SuppressMessageAttribute.cs
- StateManagedCollection.cs
- DataGridViewCellPaintingEventArgs.cs
- CodeTypeParameterCollection.cs
- XamlVector3DCollectionSerializer.cs
- Registry.cs
- SQLDecimal.cs
- DocumentXmlWriter.cs
- HtmlTernaryTree.cs
- WebPartEditorOkVerb.cs
- DataGridPageChangedEventArgs.cs
- XmlNotation.cs
- HyperLinkField.cs
- AspNetHostingPermission.cs
- OSEnvironmentHelper.cs
- TableLayoutColumnStyleCollection.cs
- Compiler.cs
- Pool.cs
- ProfileService.cs
- Typography.cs
- TrackingServices.cs
- SupportsEventValidationAttribute.cs
- SerTrace.cs
- CommandPlan.cs
- _NestedMultipleAsyncResult.cs
- Vector3DKeyFrameCollection.cs
- ChannelCacheSettings.cs
- CharacterHit.cs
- OptionalMessageQuery.cs
- InstanceCompleteException.cs
- IndexedString.cs
- Hashtable.cs
- ByteFacetDescriptionElement.cs
- FontUnitConverter.cs
- XmlAtomicValue.cs
- MetadataItem_Static.cs
- StateMachine.cs
- InstanceLockedException.cs
- ManagementEventArgs.cs
- ClientRolePrincipal.cs
- SqlPersonalizationProvider.cs
- ConcurrentBag.cs
- ConfigurationManagerHelper.cs
- XmlSerializer.cs
- TextEncodedRawTextWriter.cs
- LayoutUtils.cs
- precedingquery.cs
- PenLineJoinValidation.cs
- AspProxy.cs
- WindowsFormsSectionHandler.cs
- XmlHierarchicalDataSourceView.cs
- StateManagedCollection.cs
- ControlTemplate.cs
- SafeEventHandle.cs
- DataPagerFieldCommandEventArgs.cs
- WinInetCache.cs
- WindowsAltTab.cs
- IndexerNameAttribute.cs
- Avt.cs
- HitTestParameters3D.cs
- InternalTypeHelper.cs
- ByteAnimation.cs
- CheckBoxPopupAdapter.cs
- Graphics.cs
- RemoteCryptoRsaServiceProvider.cs
- LogicalExpr.cs
- RuleRef.cs
- Model3D.cs
- EditorBrowsableAttribute.cs
- ClientTargetCollection.cs
- SpellerStatusTable.cs
- FixUpCollection.cs
- SafeMILHandle.cs
- ParsedAttributeCollection.cs
- ObjectDataSource.cs
- regiisutil.cs
- WsatStrings.cs
- unitconverter.cs
- TextElement.cs
- TableParaClient.cs
- TabControl.cs
- StylusPointPropertyId.cs
- DoubleStorage.cs
- ContainerAction.cs
- EdmItemError.cs
- DockProviderWrapper.cs
- StandardBindingImporter.cs
- BaseResourcesBuildProvider.cs
- RegistryPermission.cs
- HtmlFormWrapper.cs
- ParserStack.cs
- ItemsPresenter.cs
- LogSwitch.cs
- TextProviderWrapper.cs
- Int64Animation.cs
- Expander.cs