proxygen
folly::NotificationQueue< MessageT >::SimpleConsumer Class Reference

#include <NotificationQueue.h>

Public Member Functions

 SimpleConsumer (NotificationQueue &queue)
 
 ~SimpleConsumer ()
 
int getFd () const
 
template<typename F >
void consumeUntilDrained (F &&foreach)
 

Private Attributes

NotificationQueuequeue_
 

Detailed Description

template<typename MessageT>
class folly::NotificationQueue< MessageT >::SimpleConsumer

Definition at line 226 of file NotificationQueue.h.

Constructor & Destructor Documentation

template<typename MessageT>
folly::NotificationQueue< MessageT >::SimpleConsumer::SimpleConsumer ( NotificationQueue queue)
inlineexplicit
template<typename MessageT>
folly::NotificationQueue< MessageT >::SimpleConsumer::~SimpleConsumer ( )
inline

Member Function Documentation

template<typename MessageT >
template<typename F >
void folly::NotificationQueue< MessageT >::SimpleConsumer::consumeUntilDrained ( F &&  foreach)

Definition at line 868 of file NotificationQueue.h.

References folly::data(), g(), folly::gen::move, folly::NotificationQueue< MessageT >::queue_, SCOPE_EXIT, and UNLIKELY.

869  {
870  SCOPE_EXIT {
872  };
873 
874  queue_.checkPid();
875 
876  while (true) {
877  std::unique_ptr<Node> data;
878  {
880 
881  if (UNLIKELY(queue_.queue_.empty())) {
882  return;
883  }
884 
885  data.reset(&queue_.queue_.front());
886  queue_.queue_.pop_front();
887  }
888 
889  RequestContextScopeGuard rctx(std::move(data->ctx_));
890  foreach(std::move(data->msg_));
891  // Make sure message destructor is called with the correct RequestContext.
892  data.reset();
893  }
894 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define SCOPE_EXIT
Definition: ScopeGuard.h:274
constexpr auto data(C &c) -> decltype(c.data())
Definition: Access.h:71
g_t g(f_t)
boost::intrusive::slist< Node, boost::intrusive::cache_last< true > > queue_
#define UNLIKELY(x)
Definition: Likely.h:48
template<typename MessageT>
int folly::NotificationQueue< MessageT >::SimpleConsumer::getFd ( ) const
inline

Member Data Documentation

template<typename MessageT>
NotificationQueue& folly::NotificationQueue< MessageT >::SimpleConsumer::queue_
private

Definition at line 244 of file NotificationQueue.h.


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