fixed potentiali unsafe usage of TCHAR in ODBC driver
[public/netxms.git] / include / nxqueue.h
CommitLineData
c25cb4a0
VK
1/*
2** NetXMS - Network Management System
cd4c8ca3 3** Copyright (C) 2003, 2004, 2005, 2006 Victor Kirhenshtein
c25cb4a0
VK
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**
cd4c8ca3 19** File: nxqueue.h
c25cb4a0
VK
20**
21**/
22
23#ifndef _nxqueue_h_
24#define _nxqueue_h_
25
b160350d 26#include <nms_util.h>
77312b6f 27
c25cb4a0
VK
28
29//
30// Queue class
31//
32
b160350d 33class LIBNETXMS_EXPORTABLE Queue
c25cb4a0
VK
34{
35private:
cd4c8ca3
VK
36 MUTEX m_mutexQueueAccess;
37 CONDITION m_condWakeup;
c25cb4a0
VK
38 void **m_pElements;
39 DWORD m_dwNumElements;
40 DWORD m_dwBufferSize;
41 DWORD m_dwFirst;
42 DWORD m_dwLast;
43 DWORD m_dwBufferIncrement;
25c85230 44 BOOL m_bShutdownFlag;
c25cb4a0 45
bb7a686c 46 void CommonInit(void);
25c85230
VK
47 void Lock() { MutexLock(m_mutexQueueAccess, INFINITE); }
48 void Unlock() { MutexUnlock(m_mutexQueueAccess); }
c25cb4a0
VK
49
50public:
bb7a686c
VK
51 Queue();
52 Queue(DWORD dwInitialSize, DWORD dwBufferIncrement = 32);
c25cb4a0
VK
53 ~Queue();
54
55 void Put(void *pObject);
25c85230
VK
56 void Insert(void *pObject);
57 void SetShutdownMode();
58 void *Get();
59 void *GetOrBlock();
60 DWORD Size() { return m_dwNumElements; }
61 void Clear();
c25cb4a0
VK
62};
63
64#endif /* _nxqueue_h_ */