69 lines
2.4 KiB
OpenEdge ABL
69 lines
2.4 KiB
OpenEdge ABL
\subsection{The Command Stack}
|
|
This is a helper class to the connection class.
|
|
Each connection to a client has a command stack associated with it. The
|
|
command stack is a stack of command strings as generated by the SICS
|
|
clients. Commands are added to the top of the command queue by the network
|
|
reader. Each time the task associated with a connection runs one command
|
|
is popped from the command stack and executed. During execution the command
|
|
stack must be locked in order to prevent commands being accepted by tasks
|
|
busy waiting for some other process to finish.
|
|
|
|
Correspondingly, the interface to the command stack looks like this:
|
|
|
|
@d costaint @{
|
|
typedef struct __costa *pCosta;
|
|
|
|
/*----------------------------- live & death ----------------------------*/
|
|
pCosta CreateCommandStack(void);
|
|
void DeleteCommandStack(pCosta self);
|
|
int SetCommandStackMaxSize(pCosta self, int iNewSize);
|
|
/*----------------------------------------------------------------------*/
|
|
int CostaTop(pCosta self, char *pCommand);
|
|
int CostaBottom(pCosta self, char *pCommand);
|
|
int CostaPop(pCosta self,char **pPtr);
|
|
/*----------------------------------------------------------------------*/
|
|
void CostaLock(pCosta self);
|
|
void CostaUnlock(pCosta self);
|
|
@}
|
|
|
|
Internally, two data structure need to be defined, the first for the
|
|
list implementing the command stack, the second for the command stack
|
|
itself.
|
|
|
|
@d costadat @{
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
typedef struct __costa {
|
|
int iLock;
|
|
int iList;
|
|
int iMaxSize;
|
|
int iCount;
|
|
} Costa;
|
|
@}
|
|
|
|
|
|
@o costa.h @{
|
|
/*-------------------------------------------------------------------------
|
|
C O S T A
|
|
|
|
A command stack implementation for SICS. To be used by each connection.
|
|
|
|
Mark Koennecke, September 1997
|
|
|
|
copyright: see implementation file.
|
|
|
|
----------------------------------------------------------------------------*/
|
|
#ifndef SICSCOSTA
|
|
#define SICSCOSTA
|
|
@<costaint@>
|
|
#endif
|
|
@}
|
|
|
|
@o costa.i @{
|
|
/*---------------------------------------------------------------------------
|
|
C O S T A
|
|
Internal data structures for the command stack.
|
|
--------------------------------------------------------------------------*/
|
|
@<costadat@>
|
|
@}
|