|
Flow 2.0.0
Flow project: Full implementation 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>
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_mt & | operator= (const Log_context_mt &src) |
Identical to Log_context API; but safe against concurrent operations on a *this. More... | |
| Log_context_mt & | operator= (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... | |
| Logger * | get_logger () const |
Identical to Log_context API; but safe against concurrent operations on a *this. More... | |
| Logger * | set_logger (Logger *logger) |
Identical to Log_context API; but safe against concurrent operations on a *this. More... | |
| const Component & | get_log_component () const |
| Identical to Log_context API. More... | |
Private Attributes | |
| util::Mutex_non_recursive | m_mutex |
Protects access to data in static_cast<Log_context&>(*this) (especially Log_context::m_logger). More... | |
Additional Inherited Members | |
Private Member Functions inherited from flow::log::Log_context | |
| Log_context (Logger *logger=nullptr) | |
| Constructs Log_context by storing the given pointer to a Logger and a null Component. More... | |
| template<typename Component_payload > | |
| Log_context (Logger *logger, Component_payload component_payload) | |
Constructs Log_context by storing the given pointer to a Logger and a new Component storing the specified generically typed payload (an enum value). More... | |
| Log_context (const Log_context &src) | |
Copy constructor that stores equal Logger* and Component values as the source. More... | |
| Log_context (Log_context &&src) | |
Move constructor that makes this equal to src, while the latter becomes as-if default-constructed. More... | |
| Log_context & | operator= (const Log_context &src) |
| Assignment operator that behaves similarly to the copy constructor. More... | |
| Log_context & | operator= (Log_context &&src) |
| Move assignment operator that behaves similarly to the move constructor. More... | |
| void | swap (Log_context &other) |
Swaps Logger pointers and Component objects held by *this and other. More... | |
| Logger * | get_logger () const |
Returns the stored Logger pointer, particularly as many FLOW_LOG_*() macros expect. More... | |
| Logger * | set_logger (Logger *logger) |
| Sets the value to be returned by the next get_logger() call; returns get_logger() from before the change. More... | |
| const Component & | get_log_component () const |
Returns reference to the stored Component object, particularly as many FLOW_LOG_*() macros expect. More... | |
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.
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.
|
explicit |
|
explicit |
Identical to Log_context API.
| Component_payload | See above. |
| logger | See above. |
| component_payload | See above. |
|
explicit |
Identical to Log_context API.
| src | See above. |
Definition at line 252 of file log.cpp.
References m_mutex, and flow::log::Log_context::operator=().
| flow::log::Log_context_mt::Log_context_mt | ( | Log_context_mt && | src | ) |
Identical to Log_context API.
| src | See above. |
Definition at line 260 of file log.cpp.
References m_mutex, swap(), and flow::log::swap().
| const Component & flow::log::Log_context_mt::get_log_component | ( | ) | const |
Identical to Log_context API.
Definition at line 333 of file log.cpp.
References flow::log::Log_context::get_log_component(), and m_mutex.
| Logger * flow::log::Log_context_mt::get_logger | ( | ) | const |
Identical to Log_context API; but safe against concurrent operations on a *this.
Definition at line 321 of file log.cpp.
References flow::log::Log_context::get_logger(), and m_mutex.
| 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.
| src | See above. |
Definition at line 271 of file log.cpp.
References m_mutex, and flow::log::Log_context::operator=().
| 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.
| src | See above. |
Definition at line 298 of file log.cpp.
References m_mutex, flow::log::Log_context::operator=(), swap(), and flow::log::swap().
Identical to Log_context API; but safe against concurrent operations on a *this.
| logger | See above. |
Definition at line 327 of file log.cpp.
References m_mutex, and flow::log::Log_context::set_logger().
| void flow::log::Log_context_mt::swap | ( | Log_context_mt & | other | ) |
Identical to Log_context API; but safe against concurrent operations on a *this.
| other | See above. |
Definition at line 339 of file log.cpp.
References m_mutex, swap(), and flow::log::swap().
Referenced by Log_context_mt(), operator=(), swap(), and flow::log::swap().
|
mutableprivate |
Protects access to data in static_cast<Log_context&>(*this) (especially Log_context::m_logger).
Definition at line 1861 of file log.hpp.
Referenced by get_log_component(), get_logger(), Log_context_mt(), operator=(), set_logger(), and swap().