Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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; } } } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ContractBase.cs
- Funcletizer.cs
- MouseWheelEventArgs.cs
- DeferredElementTreeState.cs
- TextInfo.cs
- GridViewItemAutomationPeer.cs
- XmlConvert.cs
- MessageVersion.cs
- HostedElements.cs
- ActivityMarkupSerializer.cs
- SortedList.cs
- DataViewSettingCollection.cs
- CookieParameter.cs
- SplitterCancelEvent.cs
- HijriCalendar.cs
- WizardSideBarListControlItem.cs
- Assert.cs
- LogStore.cs
- TablePattern.cs
- StickyNoteContentControl.cs
- ComponentDesigner.cs
- DocumentReference.cs
- VScrollBar.cs
- ProviderCommandInfoUtils.cs
- URLMembershipCondition.cs
- HostingEnvironmentException.cs
- ComponentDispatcher.cs
- Highlights.cs
- TreeNodeClickEventArgs.cs
- AssociationSetEnd.cs
- TextBoxBase.cs
- RoutedEventHandlerInfo.cs
- DeploymentExceptionMapper.cs
- IIS7WorkerRequest.cs
- PointLight.cs
- BaseHashHelper.cs
- RegexTree.cs
- EnumBuilder.cs
- CorePropertiesFilter.cs
- ReadContentAsBinaryHelper.cs
- DataSourceView.cs
- PageContentCollection.cs
- XmlAnyElementAttributes.cs
- HtmlTextArea.cs
- HandlerBase.cs
- RegexParser.cs
- DeferredReference.cs
- LocatorPart.cs
- DiscoveryClientDocuments.cs
- ParamArrayAttribute.cs
- Journal.cs
- FigureParaClient.cs
- glyphs.cs
- ServiceHostingEnvironment.cs
- ClickablePoint.cs
- GenericPrincipal.cs
- MouseCaptureWithinProperty.cs
- MethodRental.cs
- IdentityModelDictionary.cs
- SessionEndingEventArgs.cs
- AnimatedTypeHelpers.cs
- TypeConvertions.cs
- LocalizableAttribute.cs
- DataView.cs
- SlotInfo.cs
- ApplicationException.cs
- LiteralTextContainerControlBuilder.cs
- WeakHashtable.cs
- MulticastDelegate.cs
- Rect.cs
- StoreAnnotationsMap.cs
- ListViewItem.cs
- TemplateBindingExtensionConverter.cs
- ImmutableObjectAttribute.cs
- Inline.cs
- XhtmlBasicLiteralTextAdapter.cs
- PeerCollaboration.cs
- ApplicationServicesHostFactory.cs
- MultipleViewProviderWrapper.cs
- ManagementOperationWatcher.cs
- Codec.cs
- CommandBinding.cs
- TraceSource.cs
- ThumbButtonInfo.cs
- PagesChangedEventArgs.cs
- NotSupportedException.cs
- GridItemPatternIdentifiers.cs
- Symbol.cs
- PermissionSetEnumerator.cs
- ModelItemCollection.cs
- OptionUsage.cs
- SettingsBindableAttribute.cs
- XmlSignatureProperties.cs
- DataGridViewComboBoxColumn.cs
- LayoutTable.cs
- TypeConverterAttribute.cs
- webbrowsersite.cs
- SocketAddress.cs
- BrowsableAttribute.cs
- MobileCapabilities.cs