Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / 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. //------------------------------------------------------------------------------ //// 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SpecialNameAttribute.cs
- TypeLoadException.cs
- XmlStreamStore.cs
- TypeCollectionDesigner.xaml.cs
- BuildResultCache.cs
- CodeMethodReturnStatement.cs
- File.cs
- CapabilitiesRule.cs
- LinqDataView.cs
- Unit.cs
- CollectionDataContractAttribute.cs
- LabelLiteral.cs
- TemplateNodeContextMenu.cs
- MaterializeFromAtom.cs
- CodeTypeReferenceExpression.cs
- ListParagraph.cs
- Scheduler.cs
- SynchronizedDispatch.cs
- BufferedReadStream.cs
- WinOEToolBoxItem.cs
- ImageMap.cs
- PreviewPrintController.cs
- SimpleWorkerRequest.cs
- DeclarationUpdate.cs
- Int64Storage.cs
- WindowsRegion.cs
- WindowsScrollBarBits.cs
- SolidColorBrush.cs
- StaticExtension.cs
- UTF32Encoding.cs
- ObjectParameterCollection.cs
- RenderingBiasValidation.cs
- DocumentOrderComparer.cs
- SetterBase.cs
- SizeChangedInfo.cs
- ExpressionBinding.cs
- CodeExporter.cs
- SessionStateContainer.cs
- ResourcePermissionBaseEntry.cs
- TransformPatternIdentifiers.cs
- SqlDataAdapter.cs
- DiagnosticsConfiguration.cs
- Triangle.cs
- RuntimeIdentifierPropertyAttribute.cs
- UpDownEvent.cs
- MessageFilterException.cs
- UIPermission.cs
- ComplexTypeEmitter.cs
- MultiViewDesigner.cs
- ClonableStack.cs
- DomainUpDown.cs
- CodeTypeDelegate.cs
- ObjectToIdCache.cs
- CheckoutException.cs
- DbDeleteCommandTree.cs
- HttpProfileGroupBase.cs
- WebBaseEventKeyComparer.cs
- CorrelationResolver.cs
- EventLogException.cs
- ConfigWriter.cs
- ActivityWithResultValueSerializer.cs
- RawStylusActions.cs
- MultiTrigger.cs
- InstanceDescriptor.cs
- BoundColumn.cs
- DrawingAttributesDefaultValueFactory.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- NegotiateStream.cs
- TableLayoutPanelCellPosition.cs
- MenuItemAutomationPeer.cs
- AssociationSet.cs
- ElementFactory.cs
- _ChunkParse.cs
- MeshGeometry3D.cs
- ConnectionInterfaceCollection.cs
- XmlSchemaType.cs
- WebCategoryAttribute.cs
- TextFormatterHost.cs
- RawStylusInput.cs
- WindowsListViewScroll.cs
- CharEntityEncoderFallback.cs
- ToolBarPanel.cs
- ContextMenu.cs
- DelimitedListTraceListener.cs
- RegexWriter.cs
- ObjectManager.cs
- WebPartHeaderCloseVerb.cs
- SelectionRangeConverter.cs
- SQLInt16Storage.cs
- RangeContentEnumerator.cs
- RenamedEventArgs.cs
- BamlBinaryReader.cs
- ModelTreeEnumerator.cs
- WindowPattern.cs
- CheckBox.cs
- FileLoadException.cs
- FormsAuthentication.cs
- MsmqPoisonMessageException.cs
- Timer.cs
- TextSpanModifier.cs