Server code now uses DLxxx functions from libnetxms and NxLoadConfig() for config...
[public/netxms.git] / src / server / core / nxqueue.h
CommitLineData
c25cb4a0
VK
1/*
2** NetXMS - Network Management System
3** Copyright (C) 2003, 2004 Victor Kirhenshtein
4**
5** This program is free software; you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation; either version 2 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program; if not, write to the Free Software
17** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18**
19** $module: nxqueue.h
20**
21**/
22
23#ifndef _nxqueue_h_
24#define _nxqueue_h_
25
26
27//
28// Queue class
29//
30
31class Queue
32{
33private:
34 MUTEX m_hQueueAccess;
35 CONDITION m_hConditionNotEmpty;
36 void **m_pElements;
37 DWORD m_dwNumElements;
38 DWORD m_dwBufferSize;
39 DWORD m_dwFirst;
40 DWORD m_dwLast;
41 DWORD m_dwBufferIncrement;
42
43 void Lock(void) { MutexLock(m_hQueueAccess, INFINITE); }
44 void Unlock(void) { MutexUnlock(m_hQueueAccess); }
45
46public:
47 Queue(DWORD dwInitialSize = 256, DWORD dwBufferIncrement = 32);
48 ~Queue();
49
50 void Put(void *pObject);
51 void *Get(void);
52 void *GetOrBlock(void);
53 DWORD Size(void) { return m_dwNumElements; }
54};
55
56#endif /* _nxqueue_h_ */