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
- Int16AnimationBase.cs
- TypedRowHandler.cs
- HTTPNotFoundHandler.cs
- EventDriven.cs
- SelectionRange.cs
- InvokeWebServiceDesigner.cs
- PageClientProxyGenerator.cs
- WindowsSysHeader.cs
- IOException.cs
- ToolboxItemWrapper.cs
- PolyQuadraticBezierSegment.cs
- NotCondition.cs
- diagnosticsswitches.cs
- WasHttpHandlersInstallComponent.cs
- SQLBytes.cs
- WebPartZoneAutoFormat.cs
- DataGridViewCellFormattingEventArgs.cs
- AllMembershipCondition.cs
- ConnectionManagementElementCollection.cs
- TextLineResult.cs
- CallSite.cs
- EventMappingSettingsCollection.cs
- securestring.cs
- XmlReflectionMember.cs
- MobileControlPersister.cs
- JsonWriterDelegator.cs
- TextParagraphView.cs
- GenericPrincipal.cs
- ScrollEvent.cs
- SchemaImporter.cs
- cookiecollection.cs
- ObjectContext.cs
- ResourceContainerWrapper.cs
- SafeFileHandle.cs
- SiteMapNodeItem.cs
- CmsUtils.cs
- PrintControllerWithStatusDialog.cs
- PrintEvent.cs
- GenericAuthenticationEventArgs.cs
- GcHandle.cs
- DesignOnlyAttribute.cs
- FlowDocumentReaderAutomationPeer.cs
- ToolStripManager.cs
- DetailsViewDeletedEventArgs.cs
- TypeGeneratedEventArgs.cs
- Expression.cs
- RuntimeConfigLKG.cs
- elementinformation.cs
- ContentValidator.cs
- Evaluator.cs
- SmtpMail.cs
- baseaxisquery.cs
- PartialArray.cs
- SystemThemeKey.cs
- UserControlParser.cs
- ExpressionUtilities.cs
- Int16.cs
- HtmlInputHidden.cs
- DefaultParameterValueAttribute.cs
- AndCondition.cs
- HttpCachePolicy.cs
- Ticks.cs
- TypeConverterAttribute.cs
- ColumnBinding.cs
- WCFBuildProvider.cs
- DispatchChannelSink.cs
- Region.cs
- FragmentQueryKB.cs
- ProgressiveCrcCalculatingStream.cs
- WebPartsPersonalizationAuthorization.cs
- SurrogateSelector.cs
- FontStretchConverter.cs
- ConfigurationSectionGroup.cs
- HierarchicalDataBoundControl.cs
- PixelFormats.cs
- ServiceReference.cs
- DataGridPageChangedEventArgs.cs
- ListenerAdapter.cs
- Ppl.cs
- Encoder.cs
- ResolveCriteria11.cs
- SqlDataSourceWizardForm.cs
- TcpClientSocketManager.cs
- FaultPropagationQuery.cs
- ChtmlLinkAdapter.cs
- QilValidationVisitor.cs
- EntityDataReader.cs
- Timeline.cs
- SHA384.cs
- Rect3DValueSerializer.cs
- TextTreeExtractElementUndoUnit.cs
- Pair.cs
- ContextStack.cs
- ErrorWrapper.cs
- XamlReader.cs
- BindingEditor.xaml.cs
- WriteStateInfoBase.cs
- Int64AnimationUsingKeyFrames.cs
- SecurityHelper.cs
- _CookieModule.cs