BBqueue.Buffers.framed

Entities

Simple Types

Subtypes

Constants

Subprograms

Description

This unit is based on BBqueue.Buffers and uses markers in the buffer to track the size of each commited write grants. The size of consequent read grants will conrespond to the sizes of commited write grants.

It can be used to handle variable lenght packets:

Q : aliased Framed_Buffer (64); G : Write_Grant := Empty; G : Read_Grant := Empty; : Slice_Rec;

begin Grant (Q, WG, 8); -- Get a worst case grant of size 8 Commit (Q, WG, 4); -- Only commit 4 Grant (Q, WG, 8); -- Get a worst case grant of size 8 Commit (Q, WG, 5); -- Only commit 5 Read (W, RG); -- Returns a grant of size 4

Commit

procedure Commit (This : in out Framed_Buffer;
                  G    : in out Write_Grant;
                  Size :        Framed_Count := Framed_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

Framed_Buffer

type Framed_Buffer (Size   : Buffer_Size)
is limited private;

Framed_Count

subtype Framed_Count
  is Count range Count'First .. Count'Last - Max_Frame_Header_Size;

The frame can take up to 9 bytes in addition to the allocated size. The size of what can be allocated is therefore lower than for a non-framed buffer.

Grant

procedure Grant (This : in out Framed_Buffer;
                 G    : in out Write_Grant;
                 Size : Framed_Count)

Request a contiguous writeable slice of the internal buffer

Parameters
This
G
Size

Max_Frame_Header_Size

Max_Frame_Header_Size : constant := 9;

Read

procedure Read (This : in out Framed_Buffer;
                G    : in out Read_Grant)

Request contiguous readable slice from the internal buffer. The size of the returned Read_Grant will be based on the size of previously commited frames.

Parameters
This
G

Read_Grant

type Read_Grant is limited private;

Read_Grant_In_Progress

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

Release

procedure Release (This : in out Framed_Buffer;
                   G    : in out Read_Grant)

Release a readable slice. Partial releases not allowed, the full grant will be released.

Parameters
This
G

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

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 : Framed_Buffer) return Boolean
Parameters
This
Return Value