This unit is based on BBqueue.Offsets_Only and embeds an internal buffer. It provides directly usable slices of memory from its internal buffer:
Q : aliased Buffer (64); G : Write_Grant := Empty; : Slice_Rec;
begin Grant (Q, WG, 8); if State (WG) = Valid then declare B : Storage_Array (1 .. Slice (WG).Length) with Address => Slice (WG).Addr; begin B := (others => 42); end; Commit (Q, WG); end if;
type Buffer (Size : Buffer_Size)
is limited private;
procedure Commit (This : in out Buffer;
G : in out Write_Grant;
Size : Count := Count'Last)
Commit a writeable slice. Size can be smaller than the granted slice for partial commits. The commited slice is then available for Read.
function Empty return Read_Grant
function Empty return Write_Grant
procedure Grant (This : in out Buffer;
G : in out Write_Grant;
Size : Count)
Request a contiguous writeable slice of the internal buffer
procedure Read (This : in out Buffer;
G : in out Read_Grant;
Max : Count := Count'Last)
Request contiguous readable slice of up to Max elements from the internal buffer.
type Read_Grant is limited private;
function Read_Grant_In_Progress (This : Buffer) return Boolean
procedure Release (This : in out Buffer;
G : in out Read_Grant;
Size : Count := Count'Last)
Release a readable slice. Size can be smaller than the granted slice for partial releases.
function Slice (G : Read_Grant) return Slice_Rec
function Slice (G : Write_Grant) return Slice_Rec
type Slice_Rec is record
Length : Count;
Addr : System.Address;
end record;
function State (G : Read_Grant) return Result_Kind
function State (G : Write_Grant) return Result_Kind
type Write_Grant is limited private;
function Write_Grant_In_Progress (This : Buffer) return Boolean