Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
|
#include <blocking-queue.h>
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_ |
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.
|
inline |
Definition at line 36 of file blocking-queue.h.
|
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().
|
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().
|
inline |
Definition at line 99 of file blocking-queue.h.
|
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().
|
inline |
Returns the total amount of time threads have blocked in BlockingGet.
Definition at line 105 of file blocking-queue.h.
|
inline |
Returns the total amount of time threads have blocked in BlockingPut.
Definition at line 111 of file blocking-queue.h.
|
private |
Definition at line 119 of file blocking-queue.h.
Referenced by impala::BlockingQueue< TRowBatch * >::BlockingGet(), impala::BlockingQueue< TRowBatch * >::BlockingPut(), and impala::BlockingQueue< TRowBatch * >::Shutdown().
|
private |
Definition at line 123 of file blocking-queue.h.
Referenced by impala::BlockingQueue< TRowBatch * >::BlockingGet(), impala::BlockingQueue< TRowBatch * >::BlockingPut(), and impala::BlockingQueue< TRowBatch * >::GetSize().
|
mutableprivate |
lock_ guards access to list_, total_get_wait_time, and total_put_wait_time
Definition at line 122 of file blocking-queue.h.
Referenced by impala::BlockingQueue< TRowBatch * >::BlockingGet(), impala::BlockingQueue< TRowBatch * >::BlockingPut(), impala::BlockingQueue< TRowBatch * >::GetSize(), impala::BlockingQueue< TRowBatch * >::Shutdown(), impala::BlockingQueue< TRowBatch * >::total_get_wait_time(), and impala::BlockingQueue< TRowBatch * >::total_put_wait_time().
|
private |
Definition at line 118 of file blocking-queue.h.
Referenced by impala::BlockingQueue< TRowBatch * >::BlockingPut().
|
private |
Definition at line 120 of file blocking-queue.h.
Referenced by impala::BlockingQueue< TRowBatch * >::BlockingGet(), impala::BlockingQueue< TRowBatch * >::BlockingPut(), and impala::BlockingQueue< TRowBatch * >::Shutdown().
|
private |
Definition at line 117 of file blocking-queue.h.
Referenced by impala::BlockingQueue< TRowBatch * >::BlockingGet(), impala::BlockingQueue< TRowBatch * >::BlockingPut(), and impala::BlockingQueue< TRowBatch * >::Shutdown().
|
private |
Definition at line 124 of file blocking-queue.h.
Referenced by impala::BlockingQueue< TRowBatch * >::BlockingGet(), and impala::BlockingQueue< TRowBatch * >::total_get_wait_time().
|
private |
Definition at line 125 of file blocking-queue.h.
Referenced by impala::BlockingQueue< TRowBatch * >::BlockingPut(), and impala::BlockingQueue< TRowBatch * >::total_put_wait_time().