Пример #1
0
void BufferList::Clean()
{
	Buffer **tmpBuf = m_buffers;
	m_buffers = NULL;
	Buffer *usedBuf;

	//move all used to free
	while( NULL!=(usedBuf=GetUsed(0)) )
		PutFree(usedBuf);
	//if buffers parked to this list, wait all freed
	if( tmpBuf ) {
		if( !m_usrAlloc ) {                                  //that means we allocated
			for( int i=0; i<(int)m_count; ++i ) {
				if( NULL==tmpBuf[i] ) break;         //stop on first NULL
				delete tmpBuf[i];
			}
		}
		pthread_mutex_lock(&m_freeMutex);
		while( m_freeList.size()!=m_count )
			pthread_cond_wait(&m_freeCond, &m_freeMutex);
		pthread_mutex_unlock(&m_freeMutex);
		//all buffers returned
		delete [] tmpBuf;
	}
}
Пример #2
0
void CIOCPBuffer::DUMP()
{
for(int i=0;i<(int)GetUsed();i++)
	{
	CString txt;
	BYTE b=*(GetBuffer()+i);
	txt.Format(_T("%d:%s;%d"),i,GetBuffer()+i,b);
	TRACE("%s\r\n",txt);
	}
}
Пример #3
0
void EmptyTrace::DumpEmptyTrace ( FILE *my_fp, int x, int y, int flow_block_size )
{
  // dump out the time-shifted empty trace value that gets computed
  // if this region is unused then the buffers are not initialized
  float value_to_dump = -1.0f;
  for ( int fnum=0; fnum<flow_block_size; fnum++ )
  {
    if ( GetUsed() )
	    value_to_dump = bg_dc_offset[fnum];
    fprintf ( my_fp, "%d\t%d\t%d\t%0.3f", x,y,fnum, value_to_dump);

    for ( int j=0; j<imgFrames; j++ ) {
	    if (GetUsed() )
	      value_to_dump = bg_buffers[fnum*imgFrames+j];
      fprintf ( my_fp,"\t%0.3f", value_to_dump);
    }
    fprintf ( my_fp,"\n" );
  }
}
Пример #4
0
	uint32_t CowCircularBuffer::GetBuffer(void *buf, uint32_t size)
	{
		uint32_t numToGet = 0;
		numToGet = (size < GetUsed()) ? size : GetUsed();

		if (!size)
		{
			return 0;
		}

		if ((m_EndIndex + numToGet) > m_Size)
		{
			memcpy((char *)buf, &m_Buffer[m_StartIndex], m_Size - m_StartIndex);
			memcpy(&((char *)buf)[m_Size - m_StartIndex], m_Buffer, numToGet - (m_Size - m_StartIndex));
		}
		else
		{
			memcpy(buf, &m_Buffer[m_StartIndex], numToGet);
		}

		m_StartIndex = (m_StartIndex + numToGet) % m_Size;
		return numToGet;
	}
Пример #5
0
void CMemoryStack::PrintContents()
{
	Msg( "Total used memory:      %d\n", GetUsed() );
	Msg( "Total committed memory: %d\n", GetSize() );
}
Пример #6
0
	uint32_t CowCircularBuffer::GetRemaining()
	{
		return GetSize() - GetUsed();
	}