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
- EntityClientCacheEntry.cs
- InvalidCastException.cs
- BuilderPropertyEntry.cs
- LineVisual.cs
- PeerApplicationLaunchInfo.cs
- CachingParameterInspector.cs
- PathBox.cs
- ActivatableWorkflowsQueryResult.cs
- IteratorDescriptor.cs
- TextRange.cs
- ReadOnlyCollection.cs
- XamlVector3DCollectionSerializer.cs
- DesignerObjectListAdapter.cs
- HelloOperationCD1AsyncResult.cs
- OleDbRowUpdatingEvent.cs
- SpanIndex.cs
- SiteOfOriginPart.cs
- TextBoxAutomationPeer.cs
- RoutedEventArgs.cs
- ProgressBar.cs
- OutputChannel.cs
- TreeView.cs
- ControlValuePropertyAttribute.cs
- DriveNotFoundException.cs
- TransactedBatchingElement.cs
- TableLayoutPanelResizeGlyph.cs
- _emptywebproxy.cs
- ListViewSelectEventArgs.cs
- EditorPart.cs
- QilUnary.cs
- SimpleBitVector32.cs
- UdpTransportSettingsElement.cs
- ThicknessKeyFrameCollection.cs
- TypeInfo.cs
- ResourceWriter.cs
- X509Chain.cs
- WebPartMenu.cs
- XmlTextAttribute.cs
- ZoneLinkButton.cs
- DynamicDataExtensions.cs
- NamespaceExpr.cs
- CustomPeerResolverService.cs
- GridViewDeletedEventArgs.cs
- Overlapped.cs
- ComponentDispatcher.cs
- SHA512Managed.cs
- DetailsViewRow.cs
- cache.cs
- ScrollItemProviderWrapper.cs
- DataGridView.cs
- Action.cs
- GridSplitter.cs
- ChunkedMemoryStream.cs
- OleDbException.cs
- RNGCryptoServiceProvider.cs
- XmlSchemaCompilationSettings.cs
- VisualStates.cs
- GeometryHitTestParameters.cs
- DispatcherExceptionFilterEventArgs.cs
- EpmSourceTree.cs
- FormatConvertedBitmap.cs
- DefaultValueTypeConverter.cs
- TextLineResult.cs
- formatter.cs
- XmlFormatExtensionPointAttribute.cs
- ManagedIStream.cs
- DateTimeConverter.cs
- GenericParameterDataContract.cs
- MenuEventArgs.cs
- documentsequencetextview.cs
- EntitySetDataBindingList.cs
- sqlcontext.cs
- MemberDomainMap.cs
- InstanceKeyNotReadyException.cs
- ConsoleKeyInfo.cs
- ApplicationInfo.cs
- AuthorizationSection.cs
- HttpRequestMessageProperty.cs
- XmlSigningNodeWriter.cs
- DbConnectionPoolGroup.cs
- LocalIdKeyIdentifierClause.cs
- TreeViewCancelEvent.cs
- BindingOperations.cs
- SoapProtocolImporter.cs
- HideDisabledControlAdapter.cs
- TypedElement.cs
- ProfilePropertySettingsCollection.cs
- MenuBindingsEditorForm.cs
- EdmToObjectNamespaceMap.cs
- Content.cs
- FocusWithinProperty.cs
- SortQuery.cs
- SmtpReplyReader.cs
- FlatButtonAppearance.cs
- MetafileEditor.cs
- WinCategoryAttribute.cs
- BlurBitmapEffect.cs
- SafeNativeMethods.cs
- Shape.cs
- GridViewPageEventArgs.cs