Advanced: Creating Customized OSIs : Customizing API Definitions : General API Definitions : Queue APIs

Queue APIs
 
Sample Definition
{
int tmpH = ($<nameid>.tail+1) % DEFAULT_QUEUE_SIZE;
if(tmpH != $<nameid>.head){
$<nameid>.tail = tmpH;
$<nameid>.q[$<nameid>.tail] = $<elName>;
};
}
Put <elName> at the end of queue <nameid>.
The generated code for the operation put!() for elements of type Queue.
Generated in the file <module>.c, or glob_func.c for user's functions.
For Data-Item DI_Q of type Queue, and DI_IN to put into the queue:
int tmpH = (DI_Q.tail+1) % DEFAULT_QUEUE_SIZE;
if(tmpH != DI_Q.head){
DI_Q.q[DI_Q] = DI_IN;
Queue Urgent Put(nameid, elName)
{
int tmpH = ($<nameid>.head - 1 + DEFAULT_QUEUE_SIZE) % DEFAULT_QUEUE_SIZE;
if(tmpH != $<nameid>.tail){
$<nameid>.q[$<nameid>.head] = $<elName>;
$<nameid>.head = tmpH;
};
}
Put <elName> at the beginning of queue <nameid>.
The generated code for the operation uput!() for elements of type Queue.
Generated in the file <module>.c, or glob_func.c for user's functions.
For Data-Item DI_Q of type Queue, and DI_IN to put into the queue:
int tmpH = (DI_Q.head - 1 + DEFAULT_QUEUE_SIZE) % DEFAULT_QUEUE_SIZE;
if(tmpH != DI_Q.tail){
DI_Q.q[DI_Q.head] = DI_IN;
Queue Get(nameid, elName, statElName)
?<begin> $<statElName> ?<==> ?<?>{
if($<nameid>.tail != $<nameid>.head){
$<nameid>.head = ($<nameid>.head + 1) % DEFAULT_QUEUE_SIZE;
$<elName> = $<nameid>.q[$<nameid>.head];
if($<nameid>.tail != $<nameid>.head){
$<nameid>.head = ($<nameid>.head + 1) % DEFAULT_QUEUE_SIZE;
$<elName> = $<nameid>.q[$<nameid>.head];
MAKE_TRUE($<statElName>);
else{ MAKE_FALSE($<statElName>);
Remove value from front of queue <nameid>, return value in <elName>, and set <statElName> successful.
The generated code for the operation get!() for elements of type Queue.
Generated in the file <module>.c, or glob_func.c for user's functions.
For Data-Item DI_Q of type Queue, and DI_OUT to set with the operation's value, and STAT as the status variable name:
if(DI_Q.tail != DI_Q.head){
DI_Q.head = (DI_Q.head + 1) % DEFAULT_QUEUE_SIZE;
DI_OUT = $<nameid>.q[DI_Q.head];
MAKE_TRUE(STAT);
MAKE_FALSE(STAT);
Queue Peek(nameid, elName, statElName)
?<begin> $<statElName> ?<==> ?<?>{
if($<nameid>.tail != $<nameid>.head){
$<elName> = $<nameid>.q[($<nameid>.head+1) % DEFAULT_QUEUE_SIZE];
if($<nameid>.tail != $<nameid>.head){
$<elName> = $<nameid>.q[($<nameid>.head+1) % DEFAULT_QUEUE_SIZE];
MAKE_TRUE($<statElName>);
MAKE_FALSE($<statElName>);
Copy value from front of queue <nameid>, return value in <elName>, and set <statElName> successful.
The generated code for the operation peek!() for elements of type Queue.
Generated in the file <module>.c, or glob_func.c for user's functions.
For Data-Item DI_Q of type Queue, and DI_OUT to set with the operation's value, and STAT as the status variable name:
if(DI_Q.tail != DI_Q.head){
DI_OUT = DI_Q.q[(DI_Q.head+1) % DEFAULT_QUEUE_SIZE];
MAKE_TRUE(STAT);
MAKE_FALSE(STAT);
Queue Flush(nameid)
$<nameid>.head = 0;
$<nameid>.tail = 0;
Remove all elements from queue <nameid>
The generated code for the operation fl!() for elements of type Queue.
Generated in the file <module>.c, or glob_func.c for user's functions.
For Data-Item DI_Q of type Queue:
Queue Length(nameid)
($<nameid>.head <= $<nameid>.tail ? $<nameid>.tail - $<nameid>.head : DEFAULT_QUEUE_SIZE - ($<nameid>.head - $<nameid>.tail))
Return length of Queue <nameid>
The generated code for the operation q_length() for elements of type Queue.
Generated in the file <module>.c, or glob_func.c for user's functions.
For Data-Item DI_Q of type Queue:
(DI_Q.head <= DI_Q.tail ? DI_Q.tail - DI_Q.head : DEFAULT_QUEUE_SIZE - (DI_Q.head - DI_Q.tail))