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
- PolicyVersionConverter.cs
- FixedPage.cs
- XappLauncher.cs
- ListParaClient.cs
- OutKeywords.cs
- NotificationContext.cs
- GeneralTransform3DTo2DTo3D.cs
- TaskHelper.cs
- WebUtil.cs
- dtdvalidator.cs
- TransformerConfigurationWizardBase.cs
- XmlWrappingReader.cs
- TypeBuilderInstantiation.cs
- CheckBoxRenderer.cs
- PrefixHandle.cs
- Marshal.cs
- SignedXmlDebugLog.cs
- MemberMaps.cs
- HtmlInputControl.cs
- DirectoryLocalQuery.cs
- SimpleTypeResolver.cs
- ListViewItem.cs
- CultureTable.cs
- ClientWindowsAuthenticationMembershipProvider.cs
- Highlights.cs
- RuntimeEnvironment.cs
- ProbeMatchesCD1.cs
- WebPartTransformer.cs
- DataTemplateSelector.cs
- PrincipalPermission.cs
- FontCacheLogic.cs
- TdsParserStaticMethods.cs
- RootBrowserWindowAutomationPeer.cs
- ObjectNotFoundException.cs
- Delay.cs
- RefreshPropertiesAttribute.cs
- ADMembershipUser.cs
- TextTreeExtractElementUndoUnit.cs
- Int32CollectionValueSerializer.cs
- ToolStripHighContrastRenderer.cs
- TrustLevelCollection.cs
- UniqueEventHelper.cs
- AnnotationHighlightLayer.cs
- SocketCache.cs
- XmlSchemaAll.cs
- Thumb.cs
- Style.cs
- TokenDescriptor.cs
- GridViewSortEventArgs.cs
- DebugHandleTracker.cs
- UpdatableGenericsFeature.cs
- ScriptComponentDescriptor.cs
- XmlNamedNodeMap.cs
- TableRowGroup.cs
- GraphicsPath.cs
- FileChangesMonitor.cs
- CompositeFontInfo.cs
- SmiXetterAccessMap.cs
- GridItem.cs
- dsa.cs
- PerformanceCounterManager.cs
- PackWebRequest.cs
- HtmlEncodedRawTextWriter.cs
- IdentityNotMappedException.cs
- XsltSettings.cs
- CodeCatchClause.cs
- InstanceDataCollectionCollection.cs
- WindowInteractionStateTracker.cs
- Latin1Encoding.cs
- DrawTreeNodeEventArgs.cs
- SharedStream.cs
- WebPartEditorApplyVerb.cs
- DataGridColumnDropSeparator.cs
- ShapeTypeface.cs
- UpdatableGenericsFeature.cs
- ConnectionProviderAttribute.cs
- DateTimeValueSerializerContext.cs
- BindingContext.cs
- HtmlInputReset.cs
- ListViewCommandEventArgs.cs
- Hash.cs
- LambdaReference.cs
- VisualStyleRenderer.cs
- BufferedGraphicsContext.cs
- parserscommon.cs
- EdmError.cs
- LineSegment.cs
- NotSupportedException.cs
- RegexCompiler.cs
- TypeLoadException.cs
- GeometryHitTestParameters.cs
- InternalBase.cs
- StylusPointPropertyInfoDefaults.cs
- LinqDataSourceValidationException.cs
- DateTimeParse.cs
- OrCondition.cs
- AbstractSvcMapFileLoader.cs
- TreeViewDesigner.cs
- EntityDataSourceColumn.cs
- WebAdminConfigurationHelper.cs