Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala::BlockingQueue< T > Class Template Reference

#include <blocking-queue.h>

Collaboration diagram for impala::BlockingQueue< T >:

Public Member Functions

 BlockingQueue (size_t max_elements)
 
bool BlockingGet (T *out)
 
bool BlockingPut (const T &val)
 
void Shutdown ()
 Shut down the queue. Wakes up all threads waiting on BlockingGet or BlockingPut. More...
 
uint32_t GetSize () const
 
uint64_t total_get_wait_time () const
 Returns the total amount of time threads have blocked in BlockingGet. More...
 
uint64_t total_put_wait_time () const
 Returns the total amount of time threads have blocked in BlockingPut. More...
 

Private Attributes

bool shutdown_
 
const int max_elements_
 
boost::condition_variable get_cv_
 
boost::condition_variable put_cv_
 
boost::mutex lock_
 lock_ guards access to list_, total_get_wait_time, and total_put_wait_time More...
 
std::list< T > list_
 
uint64_t total_get_wait_time_
 
uint64_t total_put_wait_time_
 

Detailed Description

template<typename T>
class impala::BlockingQueue< T >

Fixed capacity FIFO queue, where both BlockingGet and BlockingPut operations block if the queue is empty or full, respectively. TODO: Add some double-buffering so that readers do not block writers and vice versa. Or, implement a mostly lock-free blocking queue.

Definition at line 34 of file blocking-queue.h.

Constructor & Destructor Documentation

template<typename T>
impala::BlockingQueue< T >::BlockingQueue ( size_t  max_elements)
inline

Definition at line 36 of file blocking-queue.h.

Member Function Documentation

template<typename T>
bool impala::BlockingQueue< T >::BlockingGet ( T *  out)
inline

Get an element from the queue, waiting indefinitely for one to become available. Returns false if we were shut down prior to getting the element, and there are no more elements available.

Definition at line 46 of file blocking-queue.h.

Referenced by impala::MultiThreadTest::RemoverThread(), and impala::TEST().

template<typename T>
bool impala::BlockingQueue< T >::BlockingPut ( const T &  val)
inline

Puts an element into the queue, waiting indefinitely until there is space. If the queue is shut down, returns false.

Definition at line 69 of file blocking-queue.h.

Referenced by impala::MultiThreadTest::InserterThread(), and impala::TEST().

template<typename T>
uint32_t impala::BlockingQueue< T >::GetSize ( ) const
inline

Definition at line 99 of file blocking-queue.h.

template<typename T>
void impala::BlockingQueue< T >::Shutdown ( )
inline

Shut down the queue. Wakes up all threads waiting on BlockingGet or BlockingPut.

Definition at line 89 of file blocking-queue.h.

Referenced by impala::MultiThreadTest::InserterThread(), and impala::TEST().

template<typename T>
uint64_t impala::BlockingQueue< T >::total_get_wait_time ( ) const
inline

Returns the total amount of time threads have blocked in BlockingGet.

Definition at line 105 of file blocking-queue.h.

template<typename T>
uint64_t impala::BlockingQueue< T >::total_put_wait_time ( ) const
inline

Returns the total amount of time threads have blocked in BlockingPut.

Definition at line 111 of file blocking-queue.h.

Member Data Documentation

template<typename T>
const int impala::BlockingQueue< T >::max_elements_
private

Definition at line 118 of file blocking-queue.h.

Referenced by impala::BlockingQueue< TRowBatch * >::BlockingPut().

template<typename T>
uint64_t impala::BlockingQueue< T >::total_get_wait_time_
private
template<typename T>
uint64_t impala::BlockingQueue< T >::total_put_wait_time_
private

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