Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
Queue.cpp
Package: LegendOfMir2_Server020418.zip [view]
Upload User: szopptop
Upload Date: 2013-04-23
Package Size: 1047k
Code Size: 2k
Category:
Game Server Simulator
Development Platform:
Visual C++
- // **************************************************************************************
- //
- // Euyheon's Queue Class
- //
- // All written by Euy-heon, Jeong.
- // Copyright(C) 1999-2001 Euy-heon, Jeong. All rights reserved.
- //
- // Win32 Version : Compiled by Microsoft Visual C++ 6.0
- //
- // Problems & History
- // ------------------
- //
- // **************************************************************************************
- #include "stdafx.h"
- CWHQueue::CWHQueue()
- {
- // InitializeCriticalSection(&m_cs);
- m_btQPushPos = 0;
- m_btQPopPos = 0;
- m_btCount = 0;
- }
- CWHQueue::~CWHQueue()
- {
- // DeleteCriticalSection(&m_cs);
- }
- BOOL CWHQueue::PushQ(BYTE *lpbtQ)
- {
- BOOL fRet = TRUE;
- // EnterCriticalSection(&m_cs);
- __try
- {
- if (m_btQPushPos + 1 == m_btQPopPos || (m_btQPushPos + 1 == (unsigned) QUEUE_MAX && !m_btQPopPos))
- {
- fRet = FALSE;
- __leave; // Queue is full.
- }
- m_lpCircularQ[m_btQPushPos] = lpbtQ;
- m_btQPushPos++;
- m_btCount++;
- if (m_btQPushPos == (unsigned) QUEUE_MAX)
- m_btQPushPos = 0;
- }
- __finally
- {
- // LeaveCriticalSection(&m_cs);
- }
- return fRet;
- }
- BYTE *CWHQueue::PopQ()
- {
- BYTE *pbt = NULL;
- // EnterCriticalSection(&m_cs);
- __try
- {
- if (m_btQPopPos == (unsigned) QUEUE_MAX)
- m_btQPopPos = 0;
- if (m_btQPopPos == m_btQPushPos)
- __leave; // No event.
- m_btQPopPos++;
- m_btCount--;
- pbt = m_lpCircularQ[m_btQPopPos - 1];
- }
- __finally
- {
- // LeaveCriticalSection(&m_cs);
- }
- return pbt;
- }