资源简介
无锁 环形缓冲区
代码片段和文件信息
#include “stdafx.h“
#include “RingBuffer.h“
#define MAX_RING_BUFFER_SIZE (2*1024*1000)
#define MIN_RING_BUFFER_SIZE (128*1000)
#define DEFAULT_RING_BUFFER_SIZE (512*1000)
RingBuffer::RingBuffer()
{
m_iWidx = 0;
m_iRIdx = 0;
m_uBufferSize = DEFAULT_RING_BUFFER_SIZE;
m_pBuffer = new char[m_uBufferSize];
m_bOutsideBuf = false;
m_iWorkStatus = RINGBUFFER_NORMAL;
InitializeCriticalSectionAndSpinCount(&m_csBufMutex 4000);
}
RingBuffer::RingBuffer(unsigned bufferSize char* pBuffer)
{
m_iWidx = 0;
m_iRIdx = 0;
// if (bufferSize < MIN_RING_BUFFER_SIZE)
// {
// bufferSize = MIN_RING_BUFFER_SIZE;
// }
// if (bufferSize > MAX_RING_BUFFER_SIZE)
// {
// bufferSize = MAX_RING_BUFFER_SIZE;
// }
//outside buf do not check size
m_uBufferSize = buffe
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1266 2016-07-20 17:35 RingBuffer.h
文件 6128 2016-07-20 17:32 RingBuffer.cpp
文件 228 2016-08-15 17:17 ReadMe.txt
----------- --------- ---------- ----- ----
7622 3
评论
共有 条评论