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

PrevUpHomeNext

Class template unbounded_ordering_queue

boost::log::sinks::unbounded_ordering_queue — Unbounded ordering log record queueing strategy.

Synopsis

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

template<typename OrderT> 
class unbounded_ordering_queue {
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 unbounded_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();

  // private member functions
  void enqueue_unlocked(record_view const &);
};

Description

The unbounded_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 no size limits.

  • 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.

Since this queue has no size limits, it may grow uncontrollably if sink backends dequeue log records not fast enough. When this is an issue, it is recommended to use one of the bounded strategies.

unbounded_ordering_queue public construct/copy/destruct

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

unbounded_ordering_queue public member functions

  1. posix_time::time_duration get_ordering_window() const;

    Returns ordering window size specified during initialization

unbounded_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.

unbounded_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 no log records are ready to be processed.
  4. bool try_dequeue(record_view & rec);
    Attempts to dequeue log record from the queue, does not block.
  5. bool dequeue_ready(record_view & rec);
    Dequeues log record from the queue, blocks if no log records are ready to be processed.
  6. void interrupt_dequeue();
    Wakes a thread possibly blocked in the dequeue method.

unbounded_ordering_queue private member functions

  1. void enqueue_unlocked(record_view const & rec);
    Enqueues a log record.

PrevUpHomeNext