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
- ToolStripItemBehavior.cs
- EntityClassGenerator.cs
- DBCommandBuilder.cs
- ICollection.cs
- StreamWithDictionary.cs
- SelectionWordBreaker.cs
- TabControl.cs
- ErrorItem.cs
- WorkflowInvoker.cs
- ExceptionUtil.cs
- ErrorWebPart.cs
- SqlTypesSchemaImporter.cs
- ChunkedMemoryStream.cs
- HttpRequest.cs
- PropertyRef.cs
- querybuilder.cs
- Parser.cs
- PointLight.cs
- HandledEventArgs.cs
- TextEncodedRawTextWriter.cs
- ApplicationFileCodeDomTreeGenerator.cs
- OrderByQueryOptionExpression.cs
- SubpageParagraph.cs
- DbParameterCollection.cs
- WorkflowClientDeliverMessageWrapper.cs
- UIElementParagraph.cs
- ColumnMap.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- SerializationBinder.cs
- ServiceDurableInstanceContextProvider.cs
- SignatureHelper.cs
- SoapMessage.cs
- Clipboard.cs
- TabControlDesigner.cs
- RuntimeConfigurationRecord.cs
- ToolStripItemImageRenderEventArgs.cs
- MultiSelectRootGridEntry.cs
- ExpressionList.cs
- ReaderContextStackData.cs
- PrintPageEvent.cs
- IPCCacheManager.cs
- ToolStripItemImageRenderEventArgs.cs
- webbrowsersite.cs
- InsufficientExecutionStackException.cs
- UnicodeEncoding.cs
- WeakReferenceKey.cs
- TransformProviderWrapper.cs
- WebPartsSection.cs
- FormViewPageEventArgs.cs
- relpropertyhelper.cs
- CommandHelper.cs
- DataRecordObjectView.cs
- TemplateComponentConnector.cs
- RowBinding.cs
- FloaterParaClient.cs
- ReferentialConstraint.cs
- PickBranchDesigner.xaml.cs
- PeerCollaboration.cs
- SafeCertificateStore.cs
- WinFormsUtils.cs
- GenericNameHandler.cs
- QueryServiceConfigHandle.cs
- MultiView.cs
- InfocardExtendedInformationCollection.cs
- CollectionChangedEventManager.cs
- MemberInfoSerializationHolder.cs
- XPathNavigator.cs
- BuildProvidersCompiler.cs
- DataServiceConfiguration.cs
- webeventbuffer.cs
- NonBatchDirectoryCompiler.cs
- HwndAppCommandInputProvider.cs
- VoiceInfo.cs
- ObjectViewEntityCollectionData.cs
- FormatConvertedBitmap.cs
- AnchoredBlock.cs
- MetadataItemSerializer.cs
- HtmlWindowCollection.cs
- ZipPackagePart.cs
- BrowserCapabilitiesFactory.cs
- CodePageUtils.cs
- SharedDp.cs
- DetailsViewRow.cs
- StronglyTypedResourceBuilder.cs
- SessionEndedEventArgs.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- Privilege.cs
- TextFormatterImp.cs
- EntityAdapter.cs
- StyleTypedPropertyAttribute.cs
- PersistenceMetadataNamespace.cs
- RequestSecurityTokenForGetBrowserToken.cs
- BooleanKeyFrameCollection.cs
- EventHandlerList.cs
- BitmapCache.cs
- Page.cs
- Sql8ExpressionRewriter.cs
- ImageBrush.cs
- ipaddressinformationcollection.cs
- InfocardExtendedInformationCollection.cs