JANA2
C++ framework for multi-threaded data processing
JQueue Class Reference

JMailbox is a threadsafe event queue designed for communication between Arrows. More...

#include <JMailbox.h>

Inheritance diagram for JQueue:
[legend]
Collaboration diagram for JQueue:
[legend]

Public Member Functions

size_t get_threshold ()
 
size_t get_locations_count ()
 
bool is_work_stealing_enabled ()
 
void set_logger (JLogger logger)
 
void set_id (int id)
 
 JQueue (size_t threshold, size_t locations_count, bool enable_work_stealing)
 

Protected Attributes

size_t m_capacity
 
size_t m_locations_count
 
bool m_enable_work_stealing = false
 
int m_id = 0
 
JLogger m_logger
 

Detailed Description

JMailbox is a threadsafe event queue designed for communication between Arrows.

It is different from the standard data structure in the following ways:

  • pushes and pops return a Status enum, handling the problem of .size() always being stale
  • pops may fail but pushes may not
  • pushes and pops are chunked, reducing contention and handling the failure case cleanly
  • when the .reserve() method is used, the queue size is bounded
  • the underlying queue may be shared by all threads, NUMA-domain-local, or thread-local
  • the Arrow doesn't have to know anything about locality.

To handle memory locality at different granularities, we introduce the concept of a location. Each thread belongs to exactly one location, represented by contiguous unsigned ints starting at 0. While JArrows are wired to one logical JMailbox, JWorkers interact with the physical LocalQueue corresponding to their location. Locations prevent events from crossing NUMA domains as they get picked up by different JWorker threads.

Template Parameters
Tmust be moveable. Usually this is unique_ptr<JEvent>.

Improvements:

  1. Pad LocalQueue
  2. Enable work stealing

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