buffer.h

来自「缓冲 缓冲 缓冲 缓冲 缓冲 缓冲」· C头文件 代码 · 共 51 行

H
51
字号
// Buffer.h: interface for the Buffer class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_BUFFER_H__45260C30_43EF_41D8_8524_15DC368D439C__INCLUDED_)
#define AFX_BUFFER_H__45260C30_43EF_41D8_8524_15DC368D439C__INCLUDED_

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

#ifdef WIN32
#include <Process.h>
#include <afxmt.h>
#else
#include <pthread.h>
#endif

#define MAXBUFSIZE 50*1024 //50K
#define PROCEED_IO 0
#define STOP_ON_IO_END 1
#define STOP_ON_IO_ERROR 2

class Buffer  
{
public:
	Buffer();
	virtual ~Buffer();
	char *getBuf();
	int getSize();
	void setSize(int s);
	int getTag();
	void setTag(int stop);
	int lockBuf();
	int unlockBuf();
	int capacity();
	int getAvailableSpace();
protected:
	char buf[MAXBUFSIZE];
	int size; 
	//synchronization
#ifdef WIN32
	CCriticalSection mutex;
#else
	pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
	int stopTag; //flag to indicate I/O operation stops or fails on this buffer
};

#endif // !defined(AFX_BUFFER_H__45260C30_43EF_41D8_8524_15DC368D439C__INCLUDED_)

⌨️ 快捷键说明

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