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
- TempFiles.cs
- CmsUtils.cs
- UniqueConstraint.cs
- OLEDB_Enum.cs
- OutputCacheSection.cs
- TransformerConfigurationWizardBase.cs
- HtmlControl.cs
- DataTemplateSelector.cs
- LabelLiteral.cs
- Keywords.cs
- ToggleButton.cs
- ContentPresenter.cs
- RelationshipDetailsRow.cs
- XmlDataSource.cs
- MarshalDirectiveException.cs
- ColorAnimationBase.cs
- MaskedTextProvider.cs
- XmlNamedNodeMap.cs
- RuleSettingsCollection.cs
- ListViewItemSelectionChangedEvent.cs
- SplayTreeNode.cs
- ProxyWebPartManager.cs
- CollectionBase.cs
- ExeConfigurationFileMap.cs
- XmlLoader.cs
- LinkLabelLinkClickedEvent.cs
- ToolStripOverflow.cs
- BufferModeSettings.cs
- MediaTimeline.cs
- OrderPreservingPipeliningMergeHelper.cs
- DataGridViewComboBoxColumn.cs
- XmlReflectionMember.cs
- ContextInformation.cs
- Schedule.cs
- CompilationRelaxations.cs
- HtmlTable.cs
- safex509handles.cs
- storepermissionattribute.cs
- Permission.cs
- WindowsEditBoxRange.cs
- TextBoxAutoCompleteSourceConverter.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- GcHandle.cs
- TableParaClient.cs
- DiscoveryClientDocuments.cs
- NativeMethods.cs
- XmlReflectionMember.cs
- DataGridSortCommandEventArgs.cs
- DataFormats.cs
- UserControl.cs
- ContentType.cs
- OdbcEnvironment.cs
- HierarchicalDataSourceConverter.cs
- QilPatternFactory.cs
- OlePropertyStructs.cs
- Int64Converter.cs
- ContentTypeSettingClientMessageFormatter.cs
- DatagramAdapter.cs
- DataBindingCollection.cs
- HandledEventArgs.cs
- TextPattern.cs
- ControlPaint.cs
- SafeCoTaskMem.cs
- ObjectRef.cs
- Tuple.cs
- ModelVisual3D.cs
- XmlIlGenerator.cs
- CompleteWizardStep.cs
- HttpServerVarsCollection.cs
- FtpWebResponse.cs
- DtdParser.cs
- PropertyMetadata.cs
- NodeInfo.cs
- ProviderIncompatibleException.cs
- TimeSpanValidator.cs
- DiscoveryEndpointElement.cs
- PropertyNames.cs
- IdentifierCreationService.cs
- ApplicationServiceHelper.cs
- odbcmetadatafactory.cs
- SafeRegistryHandle.cs
- XmlNodeReader.cs
- LZCodec.cs
- KoreanCalendar.cs
- DesignerToolStripControlHost.cs
- DbgUtil.cs
- StylusPointPropertyInfo.cs
- IgnoreFileBuildProvider.cs
- LinkButton.cs
- EntityConnection.cs
- ControlBuilderAttribute.cs
- GenericEnumerator.cs
- StorageEntitySetMapping.cs
- QueryOperationResponseOfT.cs
- InlineUIContainer.cs
- EndPoint.cs
- DesignerDataConnection.cs
- QueryCoreOp.cs
- MouseCaptureWithinProperty.cs
- ResourcePermissionBaseEntry.cs