GNU Pth wrappers added
[public/netxms.git] / include / 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
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:
36 MUTEX m_hQueueAccess;
2e0596dd
VK
37#ifdef _WIN32
38 HANDLE m_eventWakeup;
39#else
40 pthread_mutex_t m_mutexWakeup;
41 pthread_cond_t m_condWakeup;
42#endif
43 //CONDITION m_hConditionNotEmpty;
c25cb4a0
VK
44 void **m_pElements;
45 DWORD m_dwNumElements;
46 DWORD m_dwBufferSize;
47 DWORD m_dwFirst;
48 DWORD m_dwLast;
49 DWORD m_dwBufferIncrement;
50
51 void Lock(void) { MutexLock(m_hQueueAccess, INFINITE); }
52 void Unlock(void) { MutexUnlock(m_hQueueAccess); }
53
54public:
55 Queue(DWORD dwInitialSize = 256, DWORD dwBufferIncrement = 32);
56 ~Queue();
57
58 void Put(void *pObject);
59 void *Get(void);
60 void *GetOrBlock(void);
61 DWORD Size(void) { return m_dwNumElements; }
d09b1909 62 void Clear(void);
c25cb4a0
VK
63};
64
65#endif /* _nxqueue_h_ */