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
- PrimaryKeyTypeConverter.cs
- BindingValueChangedEventArgs.cs
- XmlLanguage.cs
- ProfileGroupSettingsCollection.cs
- XmlDigitalSignatureProcessor.cs
- UriTemplateDispatchFormatter.cs
- PeerInvitationResponse.cs
- TypeContext.cs
- XmlSchemaAttributeGroup.cs
- XmlQuerySequence.cs
- ListBoxItemWrapperAutomationPeer.cs
- prefixendpointaddressmessagefiltertable.cs
- ToolStripStatusLabel.cs
- BindingListCollectionView.cs
- SystemIPInterfaceStatistics.cs
- MissingFieldException.cs
- DataListItemCollection.cs
- HtmlInputHidden.cs
- ContextQuery.cs
- TagElement.cs
- InstanceDataCollection.cs
- Debug.cs
- WindowHideOrCloseTracker.cs
- ResolveNameEventArgs.cs
- ServiceX509SecurityTokenProvider.cs
- XmlElementElement.cs
- SimpleRecyclingCache.cs
- DataGridDetailsPresenterAutomationPeer.cs
- GradientSpreadMethodValidation.cs
- BuildProvidersCompiler.cs
- BitmapFrame.cs
- InputMethodStateTypeInfo.cs
- Message.cs
- Matrix3D.cs
- Classification.cs
- ComponentCodeDomSerializer.cs
- TypeResolvingOptions.cs
- HtmlElement.cs
- ListChangedEventArgs.cs
- EntityModelSchemaGenerator.cs
- Pen.cs
- assemblycache.cs
- FamilyTypefaceCollection.cs
- ThreadAbortException.cs
- ManagedFilter.cs
- CellTreeSimplifier.cs
- ResourceExpressionBuilder.cs
- XmlBinaryWriter.cs
- DesignerGeometryHelper.cs
- ObjectItemAssemblyLoader.cs
- _LocalDataStore.cs
- MeasurementDCInfo.cs
- BaseTemplateBuildProvider.cs
- EnumType.cs
- RestClientProxyHandler.cs
- VisualBrush.cs
- BamlBinaryWriter.cs
- ValidatorUtils.cs
- HttpPostClientProtocol.cs
- ProviderConnectionPointCollection.cs
- TypeInfo.cs
- HttpValueCollection.cs
- AssertFilter.cs
- CompilerParameters.cs
- PreviewPageInfo.cs
- _ListenerRequestStream.cs
- QueryOpeningEnumerator.cs
- MultipleCopiesCollection.cs
- CodeStatementCollection.cs
- DesignTimeParseData.cs
- StreamMarshaler.cs
- SchemaElementDecl.cs
- EntityDesignerBuildProvider.cs
- StorageFunctionMapping.cs
- EndpointAddress.cs
- datacache.cs
- WebPartConnectionsEventArgs.cs
- ImpersonateTokenRef.cs
- LogEntryUtils.cs
- Win32Native.cs
- PermissionRequestEvidence.cs
- SQLBinaryStorage.cs
- PageAdapter.cs
- EncryptedKeyIdentifierClause.cs
- WebResponse.cs
- ByteConverter.cs
- BrowserCapabilitiesCompiler.cs
- EdmComplexTypeAttribute.cs
- X509DefaultServiceCertificateElement.cs
- AuthenticationSection.cs
- HWStack.cs
- OrderedEnumerableRowCollection.cs
- SafeNativeHandle.cs
- Expression.cs
- HMACSHA384.cs
- TimeStampChecker.cs
- ColorAnimationBase.cs
- SqlInfoMessageEvent.cs
- NumberAction.cs
- AppDomainShutdownMonitor.cs