Agora  1.2.0
Agora project
concurrent_queue_wrapper.h
Go to the documentation of this file.
1 
6 #ifndef CONCURRENT_QUEUE_WRAPPER_H_
7 #define CONCURRENT_QUEUE_WRAPPER_H_
8 
9 #include <cstddef>
10 
11 #include "concurrentqueue.h"
12 #include "message.h"
13 #include "symbols.h"
14 #include "utils.h"
15 
18 static inline void TryEnqueueFallback(
20  moodycamel::ProducerToken* producer_token, const EventData& event) {
21  if (!mc_queue->try_enqueue(*producer_token, event)) {
22  std::printf("Need more memory\n");
23  RtAssert(mc_queue->enqueue(*producer_token, event),
24  "Message enqueue failed");
25  }
26 }
27 
30 static inline void TryEnqueueFallback(
31  moodycamel::ConcurrentQueue<EventData>* mc_queue, const EventData& event) {
32  if (!mc_queue->try_enqueue(event)) {
33  std::printf("Need more memory\n");
34  RtAssert(mc_queue->enqueue(event), "Message enqueue failed");
35  }
36 }
37 
40 static inline void TryEnqueueBulkFallback(
42  moodycamel::ProducerToken* producer_token, const EventData* event_list,
43  size_t num_events) {
44  if (!mc_queue->try_enqueue_bulk(*producer_token, event_list, num_events)) {
45  std::printf("Need more memory\n");
46  RtAssert(mc_queue->enqueue_bulk(*producer_token, event_list, num_events),
47  "Message bulk enqueue failed\n");
48  }
49 }
50 
51 #endif // CONCURRENT_QUEUE_WRAPPER_H_
moodycamel::ProducerToken
Definition: concurrentqueue.h:630
fmt::v8::printf
auto printf(const S &fmt, const T &... args) -> int
Definition: printf.h:631
TryEnqueueFallback
static void TryEnqueueFallback(moodycamel::ConcurrentQueue< EventData > *mc_queue, moodycamel::ProducerToken *producer_token, const EventData &event)
Definition: concurrent_queue_wrapper.h:18
EventData
Definition: message.h:142
message.h
Self defined functions for message storage and passing.
moodycamel::ConcurrentQueue::enqueue
bool enqueue(T const &item)
Definition: concurrentqueue.h:974
moodycamel::ConcurrentQueue::enqueue_bulk
bool enqueue_bulk(It itemFirst, size_t count)
Definition: concurrentqueue.h:1016
moodycamel::ConcurrentQueue::try_enqueue_bulk
bool try_enqueue_bulk(It itemFirst, size_t count)
Definition: concurrentqueue.h:1080
symbols.h
moodycamel::ConcurrentQueue< EventData >
RtAssert
static void RtAssert(bool condition, const char *throw_str)
Definition: utils.h:104
TryEnqueueBulkFallback
static void TryEnqueueBulkFallback(moodycamel::ConcurrentQueue< EventData > *mc_queue, moodycamel::ProducerToken *producer_token, const EventData *event_list, size_t num_events)
Definition: concurrent_queue_wrapper.h:40
moodycamel::ConcurrentQueue::try_enqueue
bool try_enqueue(T const &item)
Definition: concurrentqueue.h:1039
concurrentqueue.h