Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_2_Build_907 / libraries / libjni-ecw / include / NCSQueue.h @ 33853

History | View | Annotate | Download (2.68 KB)

1 3538 nacho
/********************************************************
2
** Copyright 1999 Earth Resource Mapping Ltd.
3
** This document contains proprietary source code of
4
** Earth Resource Mapping Ltd, and can only be used under
5
** one of the three licenses as described in the
6
** license.txt file supplied with this distribution.
7
** See separate license.txt file for license details
8
** and conditions.
9
**
10
** This software is covered by US patent #6,442,298,
11
** #6,102,897 and #6,633,688.  Rights to use these patents
12
** is included in the license agreements.
13
**
14
** FILE:           NCSQueue.h
15
** CREATED:        Tue Mar 2 09:19:00 WST 1999
16
** AUTHOR:         Simon Cope
17
** PURPOSE:        NCS Queue header
18
** EDITS:
19
 *******************************************************/
20
21
#ifndef NCSQUEUE_H
22
#define NCSQUEUE_H
23
24
#ifdef __cplusplus
25
extern "C" {
26
#endif
27
28
#ifndef NCSTYPES_H
29
#include "NCSTypes.h"
30
#endif
31
#ifndef NCSDEFS_H
32
#include "NCSDefs.h"
33
#endif
34
#ifndef NCSMUTEX_H
35
#include "NCSMutex.h"
36
#endif
37
#ifndef NCSMEMPOOL_H
38
#include "NCSMemPool.h"
39
#endif
40
41
/*
42
** Queue Structures
43
*/
44
typedef struct NCSQueueNode {
45
        struct NCSQueueNode *pPrev;
46
        struct NCSQueueNode *pNext;
47
} NCSQueueNode;
48
49
typedef struct {
50
        UINT32                                nNodes;
51
        UINT32                                iNodeSize;
52
        UINT32                                nPeakNodes;
53
        UINT32                                nAppends;
54
        UINT32                                nInserts;
55
        UINT32                                nRemoves;
56
        NCSTimeStampMs                tsAppendTime;
57
        NCSTimeStampMs                tsInsertTime;
58
        NCSTimeStampMs                tsRemoveTime;
59
        NCSMutexStats                msQueue;
60
        NCSPoolStats                stPool;
61
} NCSQueueStats;
62
63
typedef struct {
64
        NCSMutex                        mMutex;
65
        NCSQueueStats                qsStats;
66
        BOOLEAN                                bCollectStats;
67
        struct NCSQueueNode *pFirst;
68
        struct NCSQueueNode *pLast;
69
        NCSPool                                *pPool;
70
        BOOLEAN                                bOurPool;
71
} NCSQueue;
72
73
/*
74
** Queue Macros
75
*/
76
#define NCSQueueFirstNode(pQueue)        (pQueue)->pFirst
77
#define NCSQueueLastNode(pQueue)        (pQueue)->pLast
78
#define NCSQueueNextNode(pCurr)                (pCurr)->pNext
79
#define NCSQueuePrevNode(pCurr)                (pCurr)->pPrev
80
#define NCSQueueGetNrNodes(pQueue)        (pQueue)->qsStats.nNodes
81
#define NCSQueueLock(pQueue)                NCSMutexBegin(&((pQueue)->mMutex))
82
#define NCSQueueUnLock(pQueue)                NCSMutexEnd(&((pQueue)->mMutex))
83
84
/*
85
** Queue Prototypes
86
*/
87
NCSQueue *NCSQueueCreate(NCSPool *pPool, UINT32 iQueueStructSize, UINT32 iQueueNodeSize);
88
void NCSQueueDestroy(NCSQueue *pQueue);
89
NCSQueueNode *NCSQueueCreateNode(NCSQueue *pQueue);
90
void NCSQueueDestroyNode(NCSQueue *pQueue, NCSQueueNode *pNode);
91
void NCSQueueAppendNode(NCSQueue *pQueue, NCSQueueNode *pNode);
92
void NCSQueueInsertNode(NCSQueue *pQueue, NCSQueueNode *pNode, NCSQueueNode *pCurr);
93
NCSQueueNode *NCSQueueRemoveNode(NCSQueue *pQueue, NCSQueueNode *pNode);
94
NCSQueueStats NCSQueueGetStats(NCSQueue *pQueue);
95
void NCSQueueEnableStats(NCSQueue *pQueue);
96
void NCSQueueDisableStats(NCSQueue *pQueue);
97
98
#ifdef __cplusplus
99
}
100
#endif
101
102
#endif /* NCSQUEUE_H */