MySQL 8.0.40
Source Code Documentation
|
Index in the error-log ring-buffer. More...
#include <cursor_by_error_log.h>
Public Member Functions | |
void | reset () |
Reset index. More... | |
PFS_ringbuffer_index () | |
Constructor. More... | |
void | set_at (const PFS_ringbuffer_index *other) |
Set this index to a given position. More... | |
void | set_after (const PFS_ringbuffer_index *other) |
Set our index to the element after the given one (if that is valid; otherwise, we cannot determine a next element). More... | |
log_sink_pfs_event * | get_event () |
Get event if it's still valid. More... | |
log_sink_pfs_event * | scan_next () |
Return current record (if valid), then set index to the next record. More... | |
Private Attributes | |
int | m_index |
Numeric row index. More... | |
log_sink_pfs_event * | m_event |
Pointer to an event in the ring-buffer. More... | |
ulonglong | m_timestamp |
Time-stamp we copied from the event we point to when setting this index. More... | |
Index in the error-log ring-buffer.
Has a numeric index, a pointer to an event in the buffer, and the timestamp for that event. This lets us easily check whether this index is still valid: its timestamp must be greater than or equal to that of the ring-buffer's oldest entry (the tail or "read-position"). If our timestamp is older than that value, it points to an event that has since expired.
|
inline |
Constructor.
|
inline |
Get event if it's still valid.
Caller should hold read-lock on ring-buffer.
If m_index
is 0, the index was reset, and we re-obtain the ring-buffer's read-pointer / tail. This updates m_event and m_timestamp.
If m_index
is -1 (EOF), we return nullptr
.
Otherwise, we try to obtain the event in the ring-buffer pointed to by m_event. If that event is still valid, we return it; otherwise, we return nullptr (but leave the stale pointer on the object for debugging). It is therefore vital to to determine success/failure by checking the retval rather than calling this method and then checking m_event directly!
nullptr | no event (EOF, empty buffer, or stale index) |
!=nullptr | the event this index is referring to |
|
inline |
Reset index.
|
inline |
Return current record (if valid), then set index to the next record.
Caller should hold read-lock on ring-buffer. Returned value is only valid as long as the lock is held.
Note that three states are possible: a) an event-pointer is returned, and the index points to a valid succeeding event (i.e. is not EOF): there are more elements b) an event-pointer is returned, but the index now flags EOF: this was the last element c) NULL is returned, and the index flags EOF: no event could be obtained (the buffer is empty, or we're at EOF)
Updates m_event, m_timestamp, and m_index.
nullptr | no valid record could be obtained (end of buffer etc.) |
!=nullptr | pointer to an entry in the ring-buffer |
|
inline |
Set our index to the element after the given one (if that is valid; otherwise, we cannot determine a next element).
Caller should hold read-lock on ring-buffer.
other | set our index to the position after the given one |
|
inline |
Set this index to a given position.
This copies other
without validating it.
other | set our index from the given one |
|
private |
Pointer to an event in the ring-buffer.
Before dereferencing this pointer, use
|
private |
Numeric row index.
valid range [0;num_events[. -1 == EOF
|
private |
Time-stamp we copied from the event we point to when setting this index.
The ring-buffer keeps track of what the oldest item in it is. If our timestamp is older than that item's timestamp, the event we're pointing too has been purged from the ring-buffer, and our pointer is stale. 0 for undefined.