Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Log / System / IO / Log / LogReservationCollection.cs / 1 / LogReservationCollection.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.IO.Log { using System; using System.IO.Log; // NOTE: The reservations in the collection do not account for // header sizes, out of necessity. The reservations made // with the record sequence *do* account for header sizes. // // In order to maintain sanity, the record sequence only // deals with reservations that include the header // size. i.e., if it goes into CLFS, it has the header size // appended to it. // // So that means: If we receive a size from the collection, // add the header size to it before returning it. If we // receive a size from our code, subtract the header size // before giving it to the collection. // // Keep this straight, or else. // sealed class LogReservationCollection : ReservationCollection { LogRecordSequence recordSequence; internal LogReservationCollection(LogRecordSequence sequence) { this.recordSequence = sequence; } internal LogRecordSequence RecordSequence { get { return this.recordSequence; } } internal long GetMatchingReservation(long size) { // Reservation coming from CLFS, subtract record header // size. // size -= LogLogRecordHeader.Size; size = GetBestMatchingReservation(size); if (size == -1) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ReservationNotFound()); // Reservation coming from the collection, add record // header size. // size += LogLogRecordHeader.Size; return size; } internal void InternalAddReservation(long size) { // Reservation coming from CLFS, remove record header // size. // size -= LogLogRecordHeader.Size; ReservationMade(size); } protected override void MakeReservation(long size) { if (size < 0) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ArgumentOutOfRange("size")); // Reservation coming from collection, add record header // size. // size += LogLogRecordHeader.Size; long aligned; UnsafeNativeMethods.AlignReservedLogSingle( this.recordSequence.MarshalContext, size, out aligned); UnsafeNativeMethods.AllocReservedLog( this.recordSequence.MarshalContext, 1, ref aligned); } protected override void FreeReservation(long size) { if (size < 0) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ArgumentOutOfRange("size")); lock(this.recordSequence.LogStore.SyncRoot) { SafeMarshalContext context = this.recordSequence.InternalMarshalContext ; if(context == null || context.IsInvalid) { return; } // Reservation coming from collection, add record header // size. // size += LogLogRecordHeader.Size; long aligned; UnsafeNativeMethods.AlignReservedLogSingle( context, size, out aligned); // Adjustment must be negative, otherwise it's considered // a "set". (Yuck.) // aligned = -aligned; UnsafeNativeMethods.FreeReservedLog( context, 1, ref aligned); } } } } // 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
- ValidationErrorCollection.cs
- IChannel.cs
- input.cs
- SessionPageStateSection.cs
- ProvideValueServiceProvider.cs
- RequestCachePolicyConverter.cs
- DuplicateContext.cs
- LineUtil.cs
- SettingsPropertyIsReadOnlyException.cs
- _SecureChannel.cs
- ConvertEvent.cs
- HashCoreRequest.cs
- BindingOperations.cs
- XmlReaderSettings.cs
- Helper.cs
- XmlHierarchicalDataSourceView.cs
- WsatConfiguration.cs
- ExtendedTransformFactory.cs
- XmlSchemaComplexType.cs
- WebPartMovingEventArgs.cs
- ElementAction.cs
- TextElement.cs
- UserControlBuildProvider.cs
- _NegotiateClient.cs
- ApplicationSecurityInfo.cs
- ByteStream.cs
- TypeExtensions.cs
- DiagnosticsConfigurationHandler.cs
- XNameConverter.cs
- XhtmlBasicControlAdapter.cs
- ListControlConvertEventArgs.cs
- MarginsConverter.cs
- PersonalizationStateQuery.cs
- DmlSqlGenerator.cs
- Encoder.cs
- GridViewSelectEventArgs.cs
- CookieProtection.cs
- CurrentChangingEventManager.cs
- XmlAnyElementAttribute.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- CapiSymmetricAlgorithm.cs
- NavigateEvent.cs
- ResolveNameEventArgs.cs
- EmbeddedMailObjectsCollection.cs
- RawUIStateInputReport.cs
- ToggleButton.cs
- ImageListImageEditor.cs
- ExpandableObjectConverter.cs
- NavigationPropertySingletonExpression.cs
- GroupItem.cs
- BitmapMetadata.cs
- WinInet.cs
- _SSPISessionCache.cs
- BitmapEffectInputData.cs
- StrokeCollectionDefaultValueFactory.cs
- DataServices.cs
- SectionInput.cs
- RegexRunnerFactory.cs
- HtmlTableCell.cs
- EqualityComparer.cs
- ModelUtilities.cs
- WebPartManagerDesigner.cs
- ToolStripSplitStackLayout.cs
- DataGridViewUtilities.cs
- SqlExpander.cs
- SoapSchemaExporter.cs
- NameTable.cs
- PriorityBinding.cs
- QilReference.cs
- ParagraphResult.cs
- SetUserLanguageRequest.cs
- Collection.cs
- DynamicValueConverter.cs
- VisualBrush.cs
- InvalidEnumArgumentException.cs
- VirtualPathExtension.cs
- __Filters.cs
- ImpersonationContext.cs
- ToolStripControlHost.cs
- EnvelopedPkcs7.cs
- LicenseContext.cs
- AutomationEvent.cs
- XmlBinaryReader.cs
- Expander.cs
- GradientSpreadMethodValidation.cs
- NotConverter.cs
- QilChoice.cs
- PersonalizableAttribute.cs
- JavaScriptSerializer.cs
- DefaultBinder.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- QuotaThrottle.cs
- ScrollableControl.cs
- storepermission.cs
- WindowsToolbarAsMenu.cs
- FieldToken.cs
- FormatException.cs
- CreateRefExpr.cs
- DLinqDataModelProvider.cs
- ThemeConfigurationDialog.cs