Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
|
#include <promise.h>
Public Member Functions | |
Promise () | |
void | Set (const T &val) |
const T & | Get () |
const T & | Get (int64_t timeout_millis, bool *timed_out) |
bool | IsSet () |
Returns whether the value is set. More... | |
Private Attributes | |
boost::condition_variable | val_set_cond_ |
bool | val_is_set_ |
boost::mutex | val_lock_ |
T | val_ |
The actual value transferred from producer to consumer. More... | |
A stripped-down replacement for boost::promise which, to the best of our knowledge, actually works. A single producer provides a single value by calling Set(..), which one or more consumers retrieve through calling Get(..). Consumers must be consistent in their use of Get(), i.e., for a particular promise all consumers should either have a timeout or not.
|
inline |
|
inline |
Blocks until a value is set, and then returns a reference to that value. Once Get() returns, the returned value will not change, since Set(..) may not be called twice.
Definition at line 59 of file promise.h.
Referenced by impala::AdmissionController::AdmitQuery(), impala::HdfsOperationSet::Execute(), impala::BlockingJoinNode::Open(), impala::ThriftThread::start(), impala::Thread::StartThread(), impala::TEST(), and impala::ResourceBroker::WaitForNotification().
|
inline |
Blocks until a value is set or the given timeout was reached. Returns a reference to that value which is invalid if the timeout was reached. Once Get() returns and *timed_out is false, the returned value will not change, since Set(..) may not be called twice. timeout_millis: The max wall-clock time in milliseconds to wait (must be > 0). timed_out: Indicates whether Get() returned due to timeout. Must be non-NULL.
|
inline |
Returns whether the value is set.
Definition at line 92 of file promise.h.
Referenced by impala::AdmissionController::AdmitQuery(), and impala::AdmissionController::DequeueLoop().
|
inline |
Copies val into this promise, and notifies any consumers blocked in Get(). It is invalid to call Set() twice.
Note: this must be called with 'val_lock_' taken. There are places where we use this object with this pattern: { Promise p; ... p.get(); } < promise object gets destroyed > Calling notify_all() with the val_lock_ guarantees that the thread calling Set() is done and the promise is safe to delete.
Definition at line 38 of file promise.h.
Referenced by impala::AdmissionController::AdmitQuery(), impala::BlockingJoinNode::BuildSideThread(), impala::AdmissionController::DequeueLoop(), impala::BufferedBlockMgrTest::GetFreeBlock(), impala::HdfsOperationSet::MarkOneOpDone(), impala::SaslAuthProvider::RunKinit(), impala::ThriftThread::RunRunnable(), impala::RunThread(), impala::Thread::SuperviseThread(), and impala::TEST().
|
private |
The actual value transferred from producer to consumer.
Definition at line 105 of file promise.h.
Referenced by impala::Promise< bool >::Get(), and impala::Promise< bool >::Set().
|
private |
Definition at line 101 of file promise.h.
Referenced by impala::Promise< bool >::Get(), impala::Promise< bool >::IsSet(), and impala::Promise< bool >::Set().
|
private |
Definition at line 102 of file promise.h.
Referenced by impala::Promise< bool >::Get(), impala::Promise< bool >::IsSet(), and impala::Promise< bool >::Set().
|
private |
These variables deal with coordination between consumer and producer, and protect access to val_;
Definition at line 100 of file promise.h.
Referenced by impala::Promise< bool >::Get(), and impala::Promise< bool >::Set().