PDFium Delphi Component Docs

TPdfRangeRequestScheduler class

Unit: PDFium
Thread-safe and transport-neutral scheduling for sparse PDF byte-range requests

Syntax

type TPdfRangeRequestScheduler = class ... end;

Methods

MethodDescription
CreateCreates an empty scheduler with two retries and no request-size limit
DestroyReleases scheduler state and its synchronisation primitive
Reset(AFileSize)Cancels active transport work, begins a new generation, clears counters and optionally enforces a logical file bound
CancelClears queued work, invalidates in-flight request generations and raises OnCancelRequest outside the scheduler lock
MarkAvailable(Offset, Size)Records externally supplied bytes, removes pending overlap and cancels redundant active transfers
EnqueueHints(Hints, Priority)Adds missing intervals, preserves exact priority and retry boundaries, and pre-empts overlapping lower-priority transfers
TryDequeue(out Request)Returns the highest-priority lowest-offset bounded request and marks it in flight
CompleteRequest(Request)Marks a complete response available after the host has stored its bytes
CompleteRequest(Request, BytesReceived)Commits a short response prefix and requeues or abandons the remainder under the retry limit
FailRequest(Request)Retries or abandons an in-flight request under MaxRetryCount
IsRangeAvailable(Offset, Size)Tests whether completed intervals fully cover a range
DataAvailableAdapts completed-range lookup to TPdfDataAvailableEvent
CopyCompletedRangesReturns a stable snapshot of merged available intervals
CopyStatisticsCopies counters through a C++Builder-friendly method

Properties and events

MemberTypeDescription
CancelledBooleanWhether the active generation has been cancelled
FileSizeUInt64Logical request bound, or zero for an unbounded standalone scheduler
MergeGapUInt64Maximum uncovered gap eligible for merging when it crosses no available or in-flight bytes
MaxRequestSizeUInt64Maximum size returned by one TryDequeue call
MaxRetryCountIntegerNumber of retries after the initial transport attempt
StatisticsTPdfRangeRequestStatisticsAtomic snapshot covering PendingRequestCount, InFlightRequestCount, AvailableRangeCount, the PendingBytes, InFlightBytes, CompletedBytes and TransferredBytes byte counters, and the FailedAttemptCount, RetriedRequestCount, AbandonedRequestCount, DequeuedRequestCount, CompletedRequestCount, PartialRequestCount, CancelledRequestCount, and SupersededRequestCount totals
OnCancelRequestTPdfRangeRequestCancelEventRequests cancellation of one active transport operation by request ID and attempt

Scheduling rules

Example

var
  Request: TPdfRangeRequest;
begin
  while Scheduler.TryDequeue(Request) do
  begin
    try
      WriteRangeResponse(Request.Offset, Request.Size);
      Scheduler.CompleteRequest(Request);
    except
      Scheduler.FailRequest(Request);
    end;
  end;
end;

Threading and transport contract

Related types

TPdfRangeRequest, TPdfRangeRequests, TPdfRangeRequestPriority, TPdfRangeRequestStatistics, TPdfRangeRequestCancelEvent, TPdfProgressiveDocument