Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / xsp / System / Web / Util / SafeBitVector32.cs / 1 / SafeBitVector32.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Threading; namespace System.Web.Util { // // This is a multithreadsafe version of System.Collections.Specialized.BitVector32. // [Serializable] internal struct SafeBitVector32 { private volatile int _data; internal SafeBitVector32(int data) { this._data = data; } #if UNUSED_CODE internal int IntegerValue { get { return _data; } set { #pragma warning disable 0420 Interlocked.Exchange(ref _data, value); #pragma warning restore 0420 } } #endif internal bool this[int bit] { get { int data = _data; return (data & bit) == bit; } set { for (;;) { int oldData = _data; int newData; if (value) { newData = oldData | bit; } else { newData = oldData & ~bit; } #pragma warning disable 0420 int result = Interlocked.CompareExchange(ref _data, newData, oldData); #pragma warning restore 0420 if (result == oldData) { break; } } } } internal bool ChangeValue(int bit, bool value) { for (;;) { int oldData = _data; int newData; if (value) { newData = oldData | bit; } else { newData = oldData & ~bit; } if (oldData == newData) { return false; } #pragma warning disable 0420 int result = Interlocked.CompareExchange(ref _data, newData, oldData); #pragma warning restore 0420 if (result == oldData) { return true; } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Threading; namespace System.Web.Util { // // This is a multithreadsafe version of System.Collections.Specialized.BitVector32. // [Serializable] internal struct SafeBitVector32 { private volatile int _data; internal SafeBitVector32(int data) { this._data = data; } #if UNUSED_CODE internal int IntegerValue { get { return _data; } set { #pragma warning disable 0420 Interlocked.Exchange(ref _data, value); #pragma warning restore 0420 } } #endif internal bool this[int bit] { get { int data = _data; return (data & bit) == bit; } set { for (;;) { int oldData = _data; int newData; if (value) { newData = oldData | bit; } else { newData = oldData & ~bit; } #pragma warning disable 0420 int result = Interlocked.CompareExchange(ref _data, newData, oldData); #pragma warning restore 0420 if (result == oldData) { break; } } } } internal bool ChangeValue(int bit, bool value) { for (;;) { int oldData = _data; int newData; if (value) { newData = oldData | bit; } else { newData = oldData & ~bit; } if (oldData == newData) { return false; } #pragma warning disable 0420 int result = Interlocked.CompareExchange(ref _data, newData, oldData); #pragma warning restore 0420 if (result == oldData) { return true; } } } } } // 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
- Camera.cs
- ClientSettingsSection.cs
- MessageHeaders.cs
- InternalBase.cs
- ComEventsHelper.cs
- XmlNamedNodeMap.cs
- SecurityProtocol.cs
- PrintPageEvent.cs
- RootAction.cs
- WindowsRichEdit.cs
- XPathSingletonIterator.cs
- ParameterModifier.cs
- AssemblyBuilder.cs
- DataSourceControlBuilder.cs
- RestClientProxyHandler.cs
- PeerNodeAddress.cs
- XmlSchemaType.cs
- AsymmetricAlgorithm.cs
- SmtpFailedRecipientsException.cs
- CLSCompliantAttribute.cs
- BaseServiceProvider.cs
- ParamArrayAttribute.cs
- SpinWait.cs
- LogEntryHeaderv1Deserializer.cs
- BuildResult.cs
- _AutoWebProxyScriptWrapper.cs
- SchemaLookupTable.cs
- XPathSelfQuery.cs
- BatchParser.cs
- DateBoldEvent.cs
- SoapExtensionTypeElement.cs
- WebBaseEventKeyComparer.cs
- ScrollViewer.cs
- Error.cs
- ReflectionUtil.cs
- TypeHelper.cs
- DataBoundControlAdapter.cs
- ContentElementAutomationPeer.cs
- GlyphsSerializer.cs
- GlyphShapingProperties.cs
- DbCommandDefinition.cs
- MimeBasePart.cs
- MetadataArtifactLoaderFile.cs
- TextMarkerSource.cs
- SerializerProvider.cs
- BookmarkUndoUnit.cs
- LinqDataSourceEditData.cs
- InstanceOwnerException.cs
- SessionPageStateSection.cs
- Cursors.cs
- DataGridViewColumnDividerDoubleClickEventArgs.cs
- InstanceValue.cs
- ControlCachePolicy.cs
- TrustLevelCollection.cs
- BoundPropertyEntry.cs
- MasterPage.cs
- CursorConverter.cs
- SoapSchemaImporter.cs
- DesignTable.cs
- UInt32Storage.cs
- MetadataCache.cs
- AssemblyUtil.cs
- PageParser.cs
- ContentType.cs
- RectIndependentAnimationStorage.cs
- StylusEventArgs.cs
- URLAttribute.cs
- ResourceAssociationSet.cs
- UnionCodeGroup.cs
- BufferBuilder.cs
- RowToFieldTransformer.cs
- InputLangChangeRequestEvent.cs
- XmlSchemaSet.cs
- MemberDescriptor.cs
- CalendarTable.cs
- MatrixAnimationUsingKeyFrames.cs
- SiteMembershipCondition.cs
- StrokeRenderer.cs
- StrokeCollectionDefaultValueFactory.cs
- RowToParametersTransformer.cs
- StylusLogic.cs
- ArrayTypeMismatchException.cs
- CompilerGeneratedAttribute.cs
- FtpWebRequest.cs
- SqlConnectionHelper.cs
- LoopExpression.cs
- TypedTableBaseExtensions.cs
- List.cs
- PropertySegmentSerializationProvider.cs
- CompositeDataBoundControl.cs
- ServerIdentity.cs
- SqlReorderer.cs
- EventProvider.cs
- SqlStream.cs
- ImageCodecInfo.cs
- path.cs
- securestring.cs
- ChineseLunisolarCalendar.cs
- ListChunk.cs
- cookiecollection.cs