⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 circularbuffer.h

📁 PW芯片方案Flash ROM烧写程序
💻 H
字号:
//---------------------------------------------------------------------------
// Pixelworks Inc. Company Confidential Strictly Private
//
// $Archive: $
// $Revision: 1.1.1.1 $
// $Author: KevinM $
// $Date: 2003/09/29 18:19:04 $
//
// --------------------------------------------------------------------------
// >>>>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// --------------------------------------------------------------------------
// Copyright 1997-2003 (c) Pixelworks Inc.
//
// Pixelworks owns the sole copyright to this software. Under international 
// copyright laws you (1) may not make a copy of this software except for 
// the purposes of maintaining a single archive copy, (2) may not derive
// works herefrom, (3) may not distribute this work to others. These rights 
// are provided for information clarification, other restrictions of rights 
// may apply as well.
//
// This is an unpublished work.
// --------------------------------------------------------------------------
// >>>>>>>>>>>>>>>>>>>>>>>>>>>> WARRANTEE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// --------------------------------------------------------------------------
// Pixelworks Inc. MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THE USE OF
// THIS SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
// PURPOSE.
// --------------------------------------------------------------------------
//
// CircularBuffer.h: interface for the CCircularBuffer class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_CIRCULARBUFFER_H__657BB4DC_55DF_4E51_821E_AFF24713C2AF__INCLUDED_)
#define AFX_CIRCULARBUFFER_H__657BB4DC_55DF_4E51_821E_AFF24713C2AF__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "afxmt.h"

class CCircularBuffer  
{
public:
	CCircularBuffer();
	CCircularBuffer(int nBufSize);

	virtual ~CCircularBuffer();

	int m_nBufferSize;
	BYTE* m_pBuffer;

	int m_nWriteIndex;
	int m_nReadIndex;

	bool m_bShutdown;

	CMutex m_Mutex;

	// Event that gets pulsed when bytes have been read from the buffer.  Used to
	// signal the AddBytes routine that more space is available.
	CEvent* m_pReadEv;

	// Event that gets pulsed when bytes have been added to the buffer.  Used to 
	// signal the ReadBytes routine that new bytes are available.
	CEvent* m_pWriteEv;

	// Add new bytes to the circular buffer.  Returns TRUE if bytes were added
	// sucessfully.
	bool AddBytes(BYTE* pBytes, int nCount, int nTimeout=100);

	// Read nCount bytes from the circular buffer, waiting if neccesary for the
	// proper number of byte to become available.
	int ReadBytes(BYTE* pBytes, int nCount, int nTimeout=100, char cMarker = 0x00);

	// Returns the number of byte available for reading.
	int  GetAvailBytes();

	// Returns the number of bytes available to write.
	int  GetAvailSpace();

	void InitMembers(int nBufSize);

	bool SetSize(int nBufSize);

	// If nCount bytes are not available in the buffer, then wait
	// for nCount bytes to become available.
	int WaitForBytes(int nCount=1, int nTimeout=INFINITE);

	void Flush();
};

#endif // !defined(AFX_CIRCULARBUFFER_H__657BB4DC_55DF_4E51_821E_AFF24713C2AF__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -