Mixe for Privacy and Anonymity in the Internet
Public Member Functions | Private Attributes | List of all members
BlockingReaderWriterQueue Class Reference

#include <readerwriterqueue.h>

Collaboration diagram for BlockingReaderWriterQueue:

Public Member Functions

 BlockingReaderWriterQueue (size_t maxSize=15) AE_NO_TSAN
 
 BlockingReaderWriterQueue (BlockingReaderWriterQueue &&other) AE_NO_TSAN
 
BlockingReaderWriterQueueoperator= (BlockingReaderWriterQueue &&other) AE_NO_TSAN
 
AE_FORCEINLINE bool enqueue (UINT8 *const &element) AE_NO_TSAN
 
bool try_dequeue (UINT8 *&result) AE_NO_TSAN
 
void wait_dequeue (UINT8 *&result) AE_NO_TSAN
 
bool wait_dequeue_timed (UINT8 *&result, std::int64_t timeout_usecs) AE_NO_TSAN
 
AE_FORCEINLINE UINT8peek () AE_NO_TSAN
 
AE_FORCEINLINE bool pop () AE_NO_TSAN
 
AE_FORCEINLINE size_t size_approx () const AE_NO_TSAN
 

Private Attributes

ReaderWriterQueue inner
 
std::unique_ptr< spsc_sema::LightweightSemaphoresema
 

Detailed Description

Definition at line 558 of file readerwriterqueue.h.

Constructor & Destructor Documentation

◆ BlockingReaderWriterQueue() [1/2]

BlockingReaderWriterQueue::BlockingReaderWriterQueue ( size_t  maxSize = 15)
inlineexplicit

Definition at line 562 of file readerwriterqueue.h.

563  : inner(maxSize), sema(new spsc_sema::LightweightSemaphore())
564  { }
std::unique_ptr< spsc_sema::LightweightSemaphore > sema

◆ BlockingReaderWriterQueue() [2/2]

BlockingReaderWriterQueue::BlockingReaderWriterQueue ( BlockingReaderWriterQueue &&  other)
inline

Definition at line 566 of file readerwriterqueue.h.

567  : inner(std::move(other.inner)), sema(std::move(other.sema))
568  { }

Member Function Documentation

◆ enqueue()

AE_FORCEINLINE bool BlockingReaderWriterQueue::enqueue ( UINT8 *const &  element)
inline

Definition at line 580 of file readerwriterqueue.h.

581  {
582  if (inner.enqueue(element)) {
583  sema->signal();
584  return true;
585  }
586  return false;
587  }
AE_FORCEINLINE bool enqueue(UINT8 *const &element) AE_NO_TSAN

References ReaderWriterQueue::enqueue(), inner, and sema.

Here is the call graph for this function:

◆ operator=()

BlockingReaderWriterQueue& BlockingReaderWriterQueue::operator= ( BlockingReaderWriterQueue &&  other)
inline

Definition at line 570 of file readerwriterqueue.h.

571  {
572  std::swap(sema, other.sema);
573  std::swap(inner, other.inner);
574  return *this;
575  }

References inner, and sema.

◆ peek()

AE_FORCEINLINE UINT8* BlockingReaderWriterQueue::peek ( )
inline

Definition at line 657 of file readerwriterqueue.h.

658  {
659  return inner.peek();
660  }
UINT8 * peek() AE_NO_TSAN

References inner, and ReaderWriterQueue::peek().

Here is the call graph for this function:

◆ pop()

AE_FORCEINLINE bool BlockingReaderWriterQueue::pop ( )
inline

Definition at line 665 of file readerwriterqueue.h.

666  {
667  if (sema->tryWait()) {
668  bool result = inner.pop();
669  assert(result);
670  AE_UNUSED(result);
671  return true;
672  }
673  return false;
674  }
#define AE_UNUSED(x)
Definition: atomicops.h:43
bool pop() AE_NO_TSAN

References AE_UNUSED, inner, ReaderWriterQueue::pop(), and sema.

Here is the call graph for this function:

◆ size_approx()

AE_FORCEINLINE size_t BlockingReaderWriterQueue::size_approx ( ) const
inline

Definition at line 678 of file readerwriterqueue.h.

679  {
680  return sema->availableApprox();
681  }

References sema.

◆ try_dequeue()

bool BlockingReaderWriterQueue::try_dequeue ( UINT8 *&  result)
inline

Definition at line 594 of file readerwriterqueue.h.

595  {
596  if (sema->tryWait()) {
597  bool success = inner.try_dequeue(result);
598  assert(success);
599  AE_UNUSED(success);
600  return true;
601  }
602  return false;
603  }
bool try_dequeue(UINT8 *&result) AE_NO_TSAN

References AE_UNUSED, inner, sema, and ReaderWriterQueue::try_dequeue().

Here is the call graph for this function:

◆ wait_dequeue()

void BlockingReaderWriterQueue::wait_dequeue ( UINT8 *&  result)
inline

Definition at line 608 of file readerwriterqueue.h.

609  {
610  sema->wait();
611  bool success = inner.try_dequeue(result);
612  AE_UNUSED(result);
613  assert(success);
614  AE_UNUSED(success);
615  }

References AE_UNUSED, inner, sema, and ReaderWriterQueue::try_dequeue().

Here is the call graph for this function:

◆ wait_dequeue_timed()

bool BlockingReaderWriterQueue::wait_dequeue_timed ( UINT8 *&  result,
std::int64_t  timeout_usecs 
)
inline

Definition at line 624 of file readerwriterqueue.h.

625  {
626  if (!sema->wait(timeout_usecs)) {
627  return false;
628  }
629  bool success = inner.try_dequeue(result);
630  AE_UNUSED(result);
631  assert(success);
632  AE_UNUSED(success);
633  return true;
634  }

References AE_UNUSED, inner, sema, and ReaderWriterQueue::try_dequeue().

Here is the call graph for this function:

Member Data Documentation

◆ inner

ReaderWriterQueue BlockingReaderWriterQueue::inner
private

◆ sema

std::unique_ptr<spsc_sema::LightweightSemaphore> BlockingReaderWriterQueue::sema
private

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