lossyque.def

来自「Welcome to PMOS. PMOS is a set of module」· DEF 代码 · 共 44 行

DEF
44
字号
DEFINITION MODULE LossyQueues;

	(****************************************************************)
	(*								*)
	(*	A lossy queue is a bounded-length queue with the	*)
	(*	property that the PutQueue operation never blocks;	*)
	(*	if space is unavailable, the data to be put are lost.	*)
	(*	This is appropriate for real-time applications where	*)
	(*	losing data is more acceptable than losing time.	*)
	(*	Of course, it is desirable to make the queue size big	*)
	(*	enough to ensure that data loss will be rare.		*)
	(*								*)
	(*	Author:		P. Moylan				*)
	(*	Last edited:	23 August 1991				*)
	(*								*)
	(*	Status:		OK.					*)
	(*								*)
	(****************************************************************)

FROM SYSTEM IMPORT
    (* type *)	BYTE;

TYPE LossyQueue;	(* is private *)

PROCEDURE CreateQueue (VAR (*OUT*) B: LossyQueue;
					capacity, elementsize: CARDINAL);

    (* Allocates space for a lossy queue, and initializes it.  The	*)
    (* caller specifies how many elements (assumed to be of equal size)	*)
    (* the queue will hold, and the size in bytes of each element.	*)

PROCEDURE PutQueue (B: LossyQueue; (*VAR*) (*IN*) item: ARRAY OF BYTE): BOOLEAN;

    (* If space is available, puts item at the tail of the queue and	*)
    (* returns TRUE.  Returns FALSE if the new item would not fit.	*)
    (* Note: it is assumed that SIZE(item) matches the element size	*)
    (* declared when the queue was created.				*)

PROCEDURE GetQueue (B: LossyQueue;  VAR (*OUT*) item: ARRAY OF BYTE);

    (* Takes one item from the head of the queue, waiting if necessary. *)

END LossyQueues.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?