proxygen
folly::UnboundedBlockingQueue< T > Class Template Reference

#include <UnboundedBlockingQueue.h>

Inheritance diagram for folly::UnboundedBlockingQueue< T >:
folly::BlockingQueue< T > UBQ< T >

Public Member Functions

virtual ~UnboundedBlockingQueue ()
 
BlockingQueueAddResult add (T item) override
 
T take () override
 
folly::Optional< Ttry_take_for (std::chrono::milliseconds time) override
 
size_t size () override
 
- Public Member Functions inherited from folly::BlockingQueue< T >
virtual ~BlockingQueue ()=default
 
virtual BlockingQueueAddResult addWithPriority (T item, int8_t)
 
virtual uint8_t getNumPriorities ()
 

Private Attributes

LifoSem sem_
 
UMPMCQueue< T, false, 6 > queue_
 

Detailed Description

template<class T>
class folly::UnboundedBlockingQueue< T >

Definition at line 26 of file UnboundedBlockingQueue.h.

Constructor & Destructor Documentation

template<class T>
virtual folly::UnboundedBlockingQueue< T >::~UnboundedBlockingQueue ( )
inlinevirtual

Definition at line 28 of file UnboundedBlockingQueue.h.

28 {}

Member Function Documentation

template<class T>
BlockingQueueAddResult folly::UnboundedBlockingQueue< T >::add ( T  item)
inlineoverridevirtual

Implements folly::BlockingQueue< T >.

Definition at line 30 of file UnboundedBlockingQueue.h.

References folly::gen::move, folly::detail::LifoSemBase< Handoff, Atom >::post(), folly::UnboundedBlockingQueue< T >::queue_, and folly::UnboundedBlockingQueue< T >::sem_.

Referenced by TEST().

30  {
31  queue_.enqueue(std::move(item));
32  return sem_.post();
33  }
UMPMCQueue< T, false, 6 > queue_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
bool post()
Silently saturates if value is already 2^32-1.
Definition: LifoSem.h:361
template<class T>
size_t folly::UnboundedBlockingQueue< T >::size ( )
inlineoverridevirtual

Implements folly::BlockingQueue< T >.

Definition at line 53 of file UnboundedBlockingQueue.h.

References folly::UnboundedBlockingQueue< T >::queue_.

Referenced by TEST().

53  {
54  return queue_.size();
55  }
UMPMCQueue< T, false, 6 > queue_
template<class T>
T folly::UnboundedBlockingQueue< T >::take ( )
inlineoverridevirtual

Implements folly::BlockingQueue< T >.

Definition at line 35 of file UnboundedBlockingQueue.h.

References folly::UnboundedBlockingQueue< T >::queue_, folly::UnboundedBlockingQueue< T >::sem_, folly::T, and folly::detail::LifoSemBase< Handoff, Atom >::wait().

Referenced by TEST().

35  {
36  T item;
37  while (!queue_.try_dequeue(item)) {
38  sem_.wait();
39  }
40  return item;
41  }
UMPMCQueue< T, false, 6 > queue_
folly::std T
template<class T>
folly::Optional<T> folly::UnboundedBlockingQueue< T >::try_take_for ( std::chrono::milliseconds  time)
inlineoverridevirtual

Implements folly::BlockingQueue< T >.

Definition at line 43 of file UnboundedBlockingQueue.h.

References folly::gen::move, folly::none, folly::UnboundedBlockingQueue< T >::queue_, folly::UnboundedBlockingQueue< T >::sem_, folly::T, and folly::detail::LifoSemBase< Handoff, Atom >::try_wait_for().

43  {
44  T item;
45  while (!queue_.try_dequeue(item)) {
46  if (!sem_.try_wait_for(time)) {
47  return folly::none;
48  }
49  }
50  return std::move(item);
51  }
UMPMCQueue< T, false, 6 > queue_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
folly::std T
bool try_wait_for(const std::chrono::duration< Rep, Period > &timeout)
Definition: LifoSem.h:472
std::chrono::nanoseconds time()
constexpr None none
Definition: Optional.h:87

Member Data Documentation


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