00001 00002 /* 00003 * THIS FILE IS UNDER RCS - DO NOT MODIFY UNLESS YOU HAVE 00004 * CHECKED IT OUT USING THE COMMAND CHECKOUT. 00005 * 00006 * $Id: mem__circ__queue_8h-source.html 2161 2006-05-19 16:55:03Z paulf $ 00007 * 00008 * Revision history: 00009 * $Log$ 00009 * Revision 1.1 2006/05/19 16:55:02 paulf 00009 * first inclusion 00009 * 00010 * Revision 1.5 2001/04/12 03:59:07 lombard 00011 * changed "peak" to "peek" 00012 * 00013 * Revision 1.4 2001/04/12 03:09:16 lombard 00014 * Added functions for saving queue to disk and recovering. 00015 * 00016 * Revision 1.3 2001/01/14 22:16:07 lombard 00017 * spelling! 00018 * 00019 * Revision 1.2 2001/01/14 22:14:44 lombard 00020 * added include file <transport.h>, required for use with mem_circ_queue. 00021 * 00022 * Revision 1.1 2000/02/14 20:05:54 lucky 00023 * Initial revision 00024 * 00025 * 00026 */ 00027 00028 00029 /* circular memory queue which allocates all its memory at startup */ 00030 00031 #ifndef MEM_CIRC_QUEUE_H 00032 #define MEM_CIRC_QUEUE_H 00033 00034 #include <transport.h> 00035 00036 /* The scheme involves three glops of memory: 00037 a small structure QUEUE - one for each queue, defined below; 00038 an array of message buffer descriptors (QUEUE_ENTRY) and 00039 a large region of message buffers where we'll store the messages 00040 (each pointed to by d in the QUEUE_ENTRY structures). 00041 */ 00042 00043 typedef char* DATA; 00044 typedef int Q_POS; 00045 00046 00047 typedef struct 00048 { 00049 long length; 00050 MSG_LOGO queueLogo; 00051 DATA d; 00052 } QUEUE_ENTRY; 00053 00054 typedef struct 00055 { 00056 QUEUE_ENTRY * pQE; /* pointer to start of queue element array */ 00057 Q_POS first; /* position of the first(oldest) element of the queue */ 00058 Q_POS last; /* position of the last(youngest) element of the queue */ 00059 long MyMaxSize; /* largest message we'll ever see */ 00060 long MyMaxElements; /* number of message buffers in ring */ 00061 long NumOfElements; 00062 00063 } QUEUE; 00064 00065 00066 int initqueue( QUEUE* q, unsigned long maxElements, unsigned long elementMaxSize ); 00067 int dequeue( QUEUE *q, DATA x, long* size, MSG_LOGO* userLogoPtr ); 00068 int enqueue( QUEUE *q, DATA x, long size, MSG_LOGO userLogo ); 00069 int getNumOfElementsInQueue( QUEUE * q); 00070 int dumpqueue( QUEUE *p, char *filename); 00071 int undumpqueue( QUEUE *q, char *filename); 00072 Q_POS getNext(QUEUE * q, int QueuePosition); 00073 Q_POS getPrev(QUEUE * q, int QueuePosition); 00074 Q_POS getPosFirst(QUEUE * q); 00075 Q_POS getPosLast(QUEUE * q); 00076 DATA peekNextElement( QUEUE *q ); 00077 00078 #endif