BBqueue.Buffers

Entities

Simple Types

Record Types

Subprograms

Description

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;

Buffer

type Buffer (Size   : Buffer_Size)
is limited private;

Commit

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.

Parameters
This
G
Size

Empty

function Empty return Read_Grant
Return Value

Empty

function Empty return Write_Grant
Return Value

Grant

procedure Grant (This : in out Buffer;
                 G    : in out Write_Grant;
                 Size : Count)

Request a contiguous writeable slice of the internal buffer

Parameters
This
G
Size

Read

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.

Parameters
This
G
Max

Read_Grant

type Read_Grant is limited private;

Read_Grant_In_Progress

function Read_Grant_In_Progress (This : Buffer) return Boolean
Parameters
This
Return Value

Release

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.

Parameters
This
G
Size

Slice

function Slice (G : Read_Grant) return Slice_Rec
Parameters
G
Return Value

Slice

function Slice (G : Write_Grant) return Slice_Rec
Parameters
G
Return Value

Slice_Rec

type Slice_Rec is record
   Length : Count;
   Addr   : System.Address;
end record;
Record fields
Length
Addr

State

function State (G : Read_Grant) return Result_Kind
Parameters
G
Return Value

State

function State (G : Write_Grant) return Result_Kind
Parameters
G
Return Value

Write_Grant

type Write_Grant is limited private;

Write_Grant_In_Progress

function Write_Grant_In_Progress (This : Buffer) return Boolean
Parameters
This
Return Value