Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Class template bounded_ordering_queue

boost::log::sinks::bounded_ordering_queue — Bounded ordering log record queueing strategy.

Synopsis

// In header: <boost/log/sinks/bounded_ordering_queue.hpp>

template<typename OrderT, std::size_t MaxQueueSizeV, 
         typename OverflowStrategyT> 
class bounded_ordering_queue : private OverflowStrategyT {
public:
  // member classes/structs/unions

  // Log record with enqueueing timestamp.

  class enqueued_record {
  public:
    // member classes/structs/unions

    // Ordering predicate.

    struct order : public OrderT {
      // types
      typedef OrderT::result_type result_type;

      // construct/copy/destruct
      order();
      order(order const &);
      order(OrderT const &);

      // public member functions
      result_type operator()(enqueued_record const &, enqueued_record const &) const;
    };
    // construct/copy/destruct
    enqueued_record(enqueued_record const &);
    enqueued_record(enqueued_record &&);
    explicit enqueued_record(record_view const &);
    enqueued_record& operator=(enqueued_record const &);
    enqueued_record& operator=(enqueued_record &&);

    // public data members
    unspecified m_timestamp;
    record_view m_record;
  };
  // construct/copy/destruct
  template<typename ArgsT> explicit bounded_ordering_queue(ArgsT const &);

  // public member functions
  posix_time::time_duration get_ordering_window() const;

  // public static functions
  static posix_time::time_duration get_default_ordering_window();

  // protected member functions
  void enqueue(record_view const &);
  bool try_enqueue(record_view const &);
  bool try_dequeue_ready(record_view &);
  bool try_dequeue(record_view &);
  bool dequeue_ready(record_view &);
  void interrupt_dequeue();
};

Description

The bounded_ordering_queue class is intended to be used with the asynchronous_sink frontend as a log record queueing strategy.

This strategy provides the following properties to the record queueing mechanism:

  • The queue has limited capacity specified by the MaxQueueSizeV template parameter.

  • Upon reaching the size limit, the queue invokes the overflow handling strategy specified in the OverflowStrategyT template parameter to handle the situation. The library provides overflow handling strategies for most common cases: drop_on_overflow will silently discard the log record, and block_on_overflow will put the enqueueing thread to wait until there is space in the queue.

  • The queue has a fixed latency window. This means that each log record put into the queue will normally not be dequeued for a certain period of time.

  • The queue performs stable record ordering within the latency window. The ordering predicate can be specified in the OrderT template parameter.

bounded_ordering_queue public construct/copy/destruct

  1. template<typename ArgsT> explicit bounded_ordering_queue(ArgsT const & args);
    Initializing constructor.

bounded_ordering_queue public member functions

  1. posix_time::time_duration get_ordering_window() const;

    Returns ordering window size specified during initialization

bounded_ordering_queue public static functions

  1. static posix_time::time_duration get_default_ordering_window();

    Returns default ordering window size. The default window size is specific to the operating system thread scheduling mechanism.

bounded_ordering_queue protected member functions

  1. void enqueue(record_view const & rec);
    Enqueues log record to the queue.
  2. bool try_enqueue(record_view const & rec);
    Attempts to enqueue log record to the queue.
  3. bool try_dequeue_ready(record_view & rec);
    Attempts to dequeue a log record ready for processing from the queue, does not block if the queue is empty.
  4. bool try_dequeue(record_view & rec);
    Attempts to dequeue log record from the queue, does not block if the queue is empty.
  5. bool dequeue_ready(record_view & rec);
    Dequeues log record from the queue, blocks if the queue is empty.
  6. void interrupt_dequeue();
    Wakes a thread possibly blocked in the dequeue method.

PrevUpHomeNext