Flow 2.0.0
Flow project: Public API.
Public Member Functions | List of all members
flow::log::Log_context_mt Class Reference

Identical to Log_context but is safe w/r/t to set_logger(), assignment, and swap() done concurrently to ops (especially get_logger()) on the same *this. More...

#include <log.hpp>

Inheritance diagram for flow::log::Log_context_mt:
[legend]
Collaboration diagram for flow::log::Log_context_mt:
[legend]

Public Member Functions

 Log_context_mt (Logger *logger=nullptr)
 Identical to Log_context API. More...
 
template<typename Component_payload >
 Log_context_mt (Logger *logger, Component_payload component_payload)
 Identical to Log_context API. More...
 
 Log_context_mt (const Log_context_mt &src)
 Identical to Log_context API. More...
 
 Log_context_mt (Log_context_mt &&src)
 Identical to Log_context API. More...
 
Log_context_mtoperator= (const Log_context_mt &src)
 Identical to Log_context API; but safe against concurrent operations on a *this. More...
 
Log_context_mtoperator= (Log_context_mt &&src)
 Identical to Log_context API; but safe against concurrent operations on a *this. More...
 
void swap (Log_context_mt &other)
 Identical to Log_context API; but safe against concurrent operations on a *this. More...
 
Loggerget_logger () const
 Identical to Log_context API; but safe against concurrent operations on a *this. More...
 
Loggerset_logger (Logger *logger)
 Identical to Log_context API; but safe against concurrent operations on a *this. More...
 
const Componentget_log_component () const
 Identical to Log_context API. More...
 

Detailed Description

Identical to Log_context but is safe w/r/t to set_logger(), assignment, and swap() done concurrently to ops (especially get_logger()) on the same *this.

See also
Log_context doc header section "Setting the logger / thready safety."

There is a perf trade-off: essentially all operations will lock an internal mutex, proceed, then unlock. This will have a small cost when there is no lock contention (no simultaneous logging – get_logger() calls); and a larger cost when there is (when indeed there is simultaneous logging – therefore get_logger() calls). Informally: in our experience, as noted in the aforementioned doc header discussion, set_logger() is mainly used when the sub-class is instantiated statically or globally; and usually it is possible to simply avoid logging along fast-paths of such classes.

Still: it requires care. If you need to provide/use set_logger(), be mindful of this potential source of slow-down.

Constructor & Destructor Documentation

◆ Log_context_mt() [1/4]

flow::log::Log_context_mt::Log_context_mt ( Logger logger = nullptr)
explicit

Identical to Log_context API.

Parameters
loggerSee above.

◆ Log_context_mt() [2/4]

template<typename Component_payload >
flow::log::Log_context_mt::Log_context_mt ( Logger logger,
Component_payload  component_payload 
)
explicit

Identical to Log_context API.

Template Parameters
Component_payloadSee above.
Parameters
loggerSee above.
component_payloadSee above.

◆ Log_context_mt() [3/4]

flow::log::Log_context_mt::Log_context_mt ( const Log_context_mt src)
explicit

Identical to Log_context API.

Parameters
srcSee above.

◆ Log_context_mt() [4/4]

flow::log::Log_context_mt::Log_context_mt ( Log_context_mt &&  src)

Identical to Log_context API.

Parameters
srcSee above.

Member Function Documentation

◆ get_log_component()

const Component & flow::log::Log_context_mt::get_log_component ( ) const

Identical to Log_context API.

Returns
See above.

◆ get_logger()

Logger * flow::log::Log_context_mt::get_logger ( ) const

Identical to Log_context API; but safe against concurrent operations on a *this.

Returns
See above.

◆ operator=() [1/2]

Log_context_mt & flow::log::Log_context_mt::operator= ( const Log_context_mt src)

Identical to Log_context API; but safe against concurrent operations on a *this.

Parameters
srcSee above.
Returns
See above.

◆ operator=() [2/2]

Log_context_mt & flow::log::Log_context_mt::operator= ( Log_context_mt &&  src)

Identical to Log_context API; but safe against concurrent operations on a *this.

Parameters
srcSee above.
Returns
See above.

◆ set_logger()

Logger * flow::log::Log_context_mt::set_logger ( Logger logger)

Identical to Log_context API; but safe against concurrent operations on a *this.

Parameters
loggerSee above.
Returns
See above.

◆ swap()

void flow::log::Log_context_mt::swap ( Log_context_mt other)

Identical to Log_context API; but safe against concurrent operations on a *this.

Parameters
otherSee above.

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