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


Class template unlocked_sink

boost::log::sinks::unlocked_sink — Non-blocking logging sink frontend.


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

template<typename SinkBackendT> 
class unlocked_sink : public basic_sink_frontend {
  // types
  typedef SinkBackendT                    sink_backend_type;   // Sink implementation type. 
  typedef shared_ptr< sink_backend_type > locked_backend_ptr;  // Type of pointer to the backend. 

  // construct/copy/destruct
  explicit unlocked_sink(shared_ptr< sink_backend_type > const &);
  template<typename... Args> explicit unlocked_sink(Args &&...);

  // public member functions
  locked_backend_ptr locked_backend();
  virtual void consume(record_view const &);
  virtual void flush();


The sink frontend does not perform thread synchronization and simply passes logging records to the sink backend.

unlocked_sink public construct/copy/destruct

  1. unlocked_sink();

    Default constructor. Constructs the sink backend instance. Requires the backend to be default-constructible.

  2. explicit unlocked_sink(shared_ptr< sink_backend_type > const & backend);

    Constructor attaches user-constructed backend instance



    Pointer to the backend instance


    backend is not NULL.

  3. template<typename... Args> explicit unlocked_sink(Args &&... args);

    Constructor that passes arbitrary named parameters to the interprocess sink backend constructor. Refer to the backend documentation for the list of supported parameters.

unlocked_sink public member functions

  1. locked_backend_ptr locked_backend();

    Locking accessor to the attached backend.

    [Note] Note

    Does not do any actual locking, provided only for interface consistency with other frontends.

  2. virtual void consume(record_view const & rec);

    Passes the log record to the backend

  3. virtual void flush();

    The method performs flushing of any internal buffers that may hold log records. The method may take considerable time to complete and may block both the calling thread and threads attempting to put new records into the sink while this call is in progress.