// Queue.h: interface for the CQueue class.
//
//////////////////////////////////////////////////////////////////////
//========================================================================
// Class Name	: CQueue
// Purpose		: 
// Autor		: Richard Chuang
// Email		: 
// Description	: 
// Reference    : 
// Copyright    : Copyright (c) 2000-2007 Davicom Inc.  All rights reserved.
// -----------------------------------------------------------------------
// Version		: 1.0.0.0
// Update       : 2007-10-23
// Modified		: Richard Chung
// Description	: 
// -----------------------------------------------------------------------
// How to use: 
// 
#if !defined(_DAVICOM_QUEUE_H_)
#define _DAVICOM_QUEUE_H_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "stdafx.h"
#include "spinlock.h"

typedef	struct	_CQUEUE_GEN_HEADER_
{
	struct	_CQUEUE_GEN_HEADER_	*pNext;
	DWORD	dwFlags;
	PVOID	pPacket;
	USHORT	usReserved;
	USHORT	usLength;
} CQUEUE_GEN_HEADER, *PCQUEUE_GEN_HEADER;

#define	CQueueGetUserPointer(ptr)	\
	((PVOID)((DWORD)(ptr) + sizeof(CQUEUE_GEN_HEADER)))

class CQueue  
{
public:
	CQueue();
	virtual ~CQueue();
	void Enqueue(PCQUEUE_GEN_HEADER	pObject);
	PCQUEUE_GEN_HEADER	Dequeue(void);
	PCQUEUE_GEN_HEADER	GetHead(void) ;
	int	IsQueueEmpty(void);
	int	Size(void);
protected:
	CSpinlock			m_SpinLock;
	CQUEUE_GEN_HEADER	*m_pHead,*m_pTail;
};

#endif // !defined(_DAVICOM_QUEUE_H_)
