ArmNN
 22.05
MockStreamCounterBuffer Class Reference

#include <ProfilingMocks.hpp>

Inheritance diagram for MockStreamCounterBuffer:

Public Member Functions

 MockStreamCounterBuffer (unsigned int maxBufferSize=4096)
 
 ~MockStreamCounterBuffer ()
 
IPacketBufferPtr Reserve (unsigned int requestedSize, unsigned int &reservedSize) override
 
void Commit (IPacketBufferPtr &packetBuffer, unsigned int size, bool notifyConsumer=true) override
 
void Release (IPacketBufferPtr &packetBuffer) override
 
IPacketBufferPtr GetReadableBuffer () override
 
void MarkRead (IPacketBufferPtr &packetBuffer) override
 
void SetConsumer (IConsumer *consumer) override
 
void FlushReadList () override
 
unsigned int GetCommittedSize () const
 
unsigned int GetReadableSize () const
 
unsigned int GetReadSize () const
 

Detailed Description

Definition at line 281 of file ProfilingMocks.hpp.

Constructor & Destructor Documentation

◆ MockStreamCounterBuffer()

MockStreamCounterBuffer ( unsigned int  maxBufferSize = 4096)
inline

Definition at line 284 of file ProfilingMocks.hpp.

285  : m_MaxBufferSize(maxBufferSize)
286  , m_BufferList()
287  , m_CommittedSize(0)
288  , m_ReadableSize(0)
289  , m_ReadSize(0)
290  {}

◆ ~MockStreamCounterBuffer()

Definition at line 291 of file ProfilingMocks.hpp.

291 {}

Member Function Documentation

◆ Commit()

void Commit ( IPacketBufferPtr &  packetBuffer,
unsigned int  size,
bool  notifyConsumer = true 
)
inlineoverride

Definition at line 307 of file ProfilingMocks.hpp.

308  {
309  std::lock_guard<std::mutex> lock(m_Mutex);
310 
311  packetBuffer->Commit(size);
312  m_BufferList.push_back(std::move(packetBuffer));
313  m_CommittedSize += size;
314 
315  if (notifyConsumer)
316  {
317  FlushReadList();
318  }
319  }

◆ FlushReadList()

void FlushReadList ( )
inlineoverride

Definition at line 358 of file ProfilingMocks.hpp.

359  {
360  // notify consumer that packet is ready to read
361  if (m_Consumer != nullptr)
362  {
363  m_Consumer->SetReadyToRead();
364  }
365  }

◆ GetCommittedSize()

unsigned int GetCommittedSize ( ) const
inline

Definition at line 367 of file ProfilingMocks.hpp.

367 { return m_CommittedSize; }

◆ GetReadableBuffer()

IPacketBufferPtr GetReadableBuffer ( )
inlineoverride

Definition at line 328 of file ProfilingMocks.hpp.

329  {
330  std::lock_guard<std::mutex> lock(m_Mutex);
331 
332  if (m_BufferList.empty())
333  {
334  return nullptr;
335  }
336  IPacketBufferPtr buffer = std::move(m_BufferList.back());
337  m_BufferList.pop_back();
338  m_ReadableSize += buffer->GetSize();
339  return buffer;
340  }

◆ GetReadableSize()

unsigned int GetReadableSize ( ) const
inline

Definition at line 368 of file ProfilingMocks.hpp.

368 { return m_ReadableSize; }

◆ GetReadSize()

unsigned int GetReadSize ( ) const
inline

Definition at line 369 of file ProfilingMocks.hpp.

369 { return m_ReadSize; }

◆ MarkRead()

void MarkRead ( IPacketBufferPtr &  packetBuffer)
inlineoverride

Definition at line 342 of file ProfilingMocks.hpp.

343  {
344  std::lock_guard<std::mutex> lock(m_Mutex);
345 
346  m_ReadSize += packetBuffer->GetSize();
347  packetBuffer->MarkRead();
348  }

◆ Release()

void Release ( IPacketBufferPtr &  packetBuffer)
inlineoverride

Definition at line 321 of file ProfilingMocks.hpp.

322  {
323  std::lock_guard<std::mutex> lock(m_Mutex);
324 
325  packetBuffer->Release();
326  }

◆ Reserve()

IPacketBufferPtr Reserve ( unsigned int  requestedSize,
unsigned int &  reservedSize 
)
inlineoverride

Definition at line 293 of file ProfilingMocks.hpp.

294  {
295  std::lock_guard<std::mutex> lock(m_Mutex);
296 
297  reservedSize = 0;
298  if (requestedSize > m_MaxBufferSize)
299  {
300  throw arm::pipe::InvalidArgumentException("The maximum buffer size that can be requested is [" +
301  std::to_string(m_MaxBufferSize) + "] bytes");
302  }
303  reservedSize = requestedSize;
304  return std::make_unique<MockPacketBuffer>(requestedSize);
305  }

◆ SetConsumer()

void SetConsumer ( IConsumer *  consumer)
inlineoverride

Definition at line 350 of file ProfilingMocks.hpp.

351  {
352  if (consumer != nullptr)
353  {
354  m_Consumer = consumer;
355  }
356  }

The documentation for this class was generated from the following file: