|
QuickCppLib 0.10
Eliminate all the tedious hassle when making state-of-the-art C++ 14 - 23 libraries!
|
Very fast threadsafe ring buffer log. More...
#include "ringbuffer_log.hpp"
Classes | |
| class | iterator_ |
| struct | unique_id |
| Used to tag an index as being an absolute lookup of a unique counter value returned by push_back/emplace_back. More... | |
Public Types | |
| using | container_type = typename Policy::container_type |
| using | value_type = typename container_type::value_type |
| The log record type. | |
| using | size_type = typename container_type::size_type |
| The size type. | |
| using | difference_type = typename container_type::difference_type |
| The difference type. | |
| using | reference = typename container_type::reference |
| The reference type. | |
| using | const_reference = typename container_type::const_reference |
| The const reference type. | |
| using | pointer = typename container_type::pointer |
| The pointer type. | |
| using | const_pointer = typename container_type::const_pointer |
| The const pointer type. | |
| using | iterator = iterator_< ringbuffer_log, pointer, reference > |
| The iterator type. | |
| using | const_iterator = iterator_< const ringbuffer_log, const_pointer, const_reference > |
| The const iterator type. | |
| using | reverse_iterator = std::reverse_iterator< iterator > |
| The reverse iterator type. | |
| using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
| The const reverse iterator type. | |
Public Member Functions | |
| template<class... Args> | |
| ringbuffer_log (level starting_level, Args &&... args) noexcept(noexcept(container_type(std::forward< Args >(args)...))) | |
| Default construction, passes through args to container_type. | |
| ringbuffer_log (const ringbuffer_log &)=delete | |
| No copying. | |
| ringbuffer_log (ringbuffer_log &&)=delete | |
| No moving. | |
| ringbuffer_log & | operator= (const ringbuffer_log &)=delete |
| No copying. | |
| ringbuffer_log & | operator= (ringbuffer_log &&)=delete |
| No moving. | |
| void | swap (ringbuffer_log &o) noexcept |
| Swaps with another instance. | |
| level | log_level () const noexcept |
THREADSAFE Returns the log level from the instance filtered by any LogLevelChecker. | |
| level | instance_log_level () const noexcept |
| THREADSAFE Returns the current per-instance log level. | |
| void | instance_log_level (level new_level) noexcept |
| THREADSAFE Sets the current per-instance log level. | |
| bool | empty () const noexcept |
| Returns true if the log is empty. | |
| size_type | size () const noexcept |
| Returns the number of items in the log. | |
| size_type | max_size () const noexcept |
| Returns the maximum number of items in the log. | |
| std::ostream * | immediate () const noexcept |
Returns any std::ostream immediately printed to when a new log entry is added. | |
| void | immediate (std::ostream *s) noexcept |
Set any std::ostream immediately printed to when a new log entry is added. | |
| bool | valid (unique_id id) const noexcept |
| True if a unique id is still valid. | |
| reference | front () noexcept |
| Returns the front of the ringbuffer. Be careful of races with concurrent modifies. | |
| const_reference | front () const noexcept |
| Returns the front of the ringbuffer. Be careful of races with concurrent modifies. | |
| reference | operator[] (size_type pos) noexcept |
| Returns a reference to the specified element. Be careful of races with concurrent modifies. | |
| reference | operator[] (unique_id id) noexcept |
| Returns a reference to the specified element. | |
| const_reference | operator[] (size_type pos) const noexcept |
| Returns a reference to the specified element. Be careful of races with concurrent modifies. | |
| const_reference | operator[] (unique_id id) const noexcept |
| Returns a reference to the specified element. | |
| reference | back () noexcept |
| Returns the back of the ringbuffer. Be careful of races with concurrent modifies. | |
| const_reference | back () const noexcept |
| Returns the back of the ringbuffer. Be careful of races with concurrent modifies. | |
| iterator | begin () noexcept |
| Returns an iterator to the first item in the log. Be careful of races with concurrent modifies. | |
| const_iterator | begin () const noexcept |
| Returns an iterator to the first item in the log. Be careful of races with concurrent modifies. | |
| const_iterator | cbegin () const noexcept |
| Returns an iterator to the first item in the log. Be careful of races with concurrent modifies. | |
| iterator | end () noexcept |
| Returns an iterator to the item after the last in the log. Be careful of races with concurrent modifies. | |
| const_iterator | end () const noexcept |
| Returns an iterator to the item after the last in the log. Be careful of races with concurrent modifies. | |
| const_iterator | cend () const noexcept |
| Returns an iterator to the item after the last in the log. Be careful of races with concurrent modifies. | |
| void | clear () noexcept |
| Clears the log. | |
| size_type | push_back (value_type &&v) noexcept |
| THREADSAFE Logs a new item, returning its unique counter id. | |
| template<class... Args> | |
| size_type | emplace_back (level __level, Args &&... args) noexcept |
| THREADSAFE Logs a new item, returning its unique counter id. | |
Static Public Attributes | |
| static constexpr size_t | max_items = Policy::max_items |
| The maximum items to store according to Policy::max_items. If zero, use container's size(). | |
Protected Member Functions | |
| size_type | counter_to_idx (size_type counter) const noexcept |
Protected Attributes | |
| container_type | _store |
| std::atomic< level > | _instance_level |
| std::atomic< size_type > | _counter |
| std::ostream * | _immediate |
Friends | |
| template<class Parent , class Pointer , class Reference > | |
| class | iterator_ |
Very fast threadsafe ring buffer log.
Works on the basis of an always incrementing atomic<size_t> which writes into the ring buffer at modulus of the ring buffer size. Items stored per log entry are defined by the Policy class' value_type. To log an item, call the QUICKCPPLIB_RINGBUFFERLOG_ITEM_* family of macros.
Be aware iteration, indexing etc. is most recent first, so log[0] is the most recently logged item. Use the reversed iterators if you don't want this.
For simple_ringbuffer_log_policy, typical item logging times are:
with backtrace (windows): up to 33 microseconds.
| using quickcpplib::_xxx::ringbuffer_log::ringbuffer_log< Policy, LogLevelChecker >::container_type = typename Policy::container_type |
The container used to store the logged records set by Policy::container_type. Must be a ContiguousContainer.
| using quickcpplib::_xxx::ringbuffer_log::ringbuffer_log< Policy, LogLevelChecker >::value_type = typename container_type::value_type |
The log record type.
| using quickcpplib::_xxx::ringbuffer_log::ringbuffer_log< Policy, LogLevelChecker >::size_type = typename container_type::size_type |
The size type.
| using quickcpplib::_xxx::ringbuffer_log::ringbuffer_log< Policy, LogLevelChecker >::difference_type = typename container_type::difference_type |
The difference type.
| using quickcpplib::_xxx::ringbuffer_log::ringbuffer_log< Policy, LogLevelChecker >::reference = typename container_type::reference |
The reference type.
| using quickcpplib::_xxx::ringbuffer_log::ringbuffer_log< Policy, LogLevelChecker >::const_reference = typename container_type::const_reference |
The const reference type.
| using quickcpplib::_xxx::ringbuffer_log::ringbuffer_log< Policy, LogLevelChecker >::pointer = typename container_type::pointer |
The pointer type.
| using quickcpplib::_xxx::ringbuffer_log::ringbuffer_log< Policy, LogLevelChecker >::const_pointer = typename container_type::const_pointer |
The const pointer type.
| using quickcpplib::_xxx::ringbuffer_log::ringbuffer_log< Policy, LogLevelChecker >::iterator = iterator_<ringbuffer_log, pointer, reference> |
The iterator type.
| using quickcpplib::_xxx::ringbuffer_log::ringbuffer_log< Policy, LogLevelChecker >::const_iterator = iterator_<const ringbuffer_log, const_pointer, const_reference> |
The const iterator type.
| using quickcpplib::_xxx::ringbuffer_log::ringbuffer_log< Policy, LogLevelChecker >::reverse_iterator = std::reverse_iterator<iterator> |
The reverse iterator type.
| using quickcpplib::_xxx::ringbuffer_log::ringbuffer_log< Policy, LogLevelChecker >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
The const reverse iterator type.
|
inlineexplicitnoexcept |
Default construction, passes through args to container_type.
|
delete |
No copying.
|
delete |
No moving.
|
inlineprotectednoexcept |
|
delete |
No copying.
|
delete |
No moving.
|
inlinenoexcept |
Swaps with another instance.
|
inlinenoexcept |
THREADSAFE Returns the log level from the instance filtered by any LogLevelChecker.
|
inlinenoexcept |
THREADSAFE Returns the current per-instance log level.
|
inlinenoexcept |
THREADSAFE Sets the current per-instance log level.
|
inlinenoexcept |
Returns true if the log is empty.
|
inlinenoexcept |
Returns the number of items in the log.
|
inlinenoexcept |
|
inlinenoexcept |
Returns any std::ostream immediately printed to when a new log entry is added.
|
inlinenoexcept |
Set any std::ostream immediately printed to when a new log entry is added.
|
inlinenoexcept |
|
inlinenoexcept |
Returns the front of the ringbuffer. Be careful of races with concurrent modifies.
|
inlinenoexcept |
Returns the front of the ringbuffer. Be careful of races with concurrent modifies.
|
inlinenoexcept |
Returns a reference to the specified element. Be careful of races with concurrent modifies.
|
inlinenoexcept |
Returns a reference to the specified element.
|
inlinenoexcept |
Returns a reference to the specified element. Be careful of races with concurrent modifies.
|
inlinenoexcept |
Returns a reference to the specified element.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Returns an iterator to the first item in the log. Be careful of races with concurrent modifies.
|
inlinenoexcept |
Returns an iterator to the first item in the log. Be careful of races with concurrent modifies.
|
inlinenoexcept |
Returns an iterator to the first item in the log. Be careful of races with concurrent modifies.
|
inlinenoexcept |
Returns an iterator to the item after the last in the log. Be careful of races with concurrent modifies.
|
inlinenoexcept |
Returns an iterator to the item after the last in the log. Be careful of races with concurrent modifies.
|
inlinenoexcept |
Returns an iterator to the item after the last in the log. Be careful of races with concurrent modifies.
|
inlinenoexcept |
Clears the log.
|
inlinenoexcept |
THREADSAFE Logs a new item, returning its unique counter id.
|
inlinenoexcept |
THREADSAFE Logs a new item, returning its unique counter id.
|
friend |
|
staticconstexpr |
The maximum items to store according to Policy::max_items. If zero, use container's size().
|
protected |
|
protected |
|
protected |
|
protected |