18 #ifndef FOEDUS_LOG_THREAD_LOG_BUFFER_HPP_
19 #define FOEDUS_LOG_THREAD_LOG_BUFFER_HPP_
83 old_epoch_ = old_epoch;
84 new_epoch_ = new_epoch;
85 offset_begin_ = offset_begin;
280 return to + buffer_size - from;
288 if (*target >= buffer_size) {
289 *target -= buffer_size;
348 if (
UNLIKELY(commit_epoch > last_epoch)) {
349 on_new_epoch_observed(commit_epoch);
350 }
else if (
UNLIKELY(commit_epoch < last_epoch)) {
352 crash_stale_commit_epoch(commit_epoch);
403 void on_new_epoch_observed(
Epoch commit_epoch);
406 void crash_stale_commit_epoch(
Epoch commit_epoch);
426 #endif // FOEDUS_LOG_THREAD_LOG_BUFFER_HPP_
uint64_t head_to_tail_distance() const __attribute__((always_inline))
friend std::ostream & operator<<(std::ostream &o, const ThreadLogBuffer &v)
uint64_t get_offset_head() const
This marks the position where log entries start.
void publish_committed_log(Epoch commit_epoch) __attribute__((always_inline))
Called when the current transaction is successfully committed.
A thread-local log buffer.
Forward declarations of classes in log manager package.
const char * get_buffer() const
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
void wait_for_space(uint16_t required_space)
Called when we have to wait till offset_head_ advances so that we can put new logs.
Typedefs of ID types used in thread package.
void reset()
Clears this epoch variable so that it points to an invalid epoch.
uint64_t offset_end_
Where the new epoch ends.
Forward declarations of classes in root package.
Brings error stacktrace information as return value of functions.
Epoch old_epoch_
The value of new_epoch_ of the previous mark.
Epoch new_epoch_
The epoch of log entries this mark represents.
Typical implementation of Initializable as a skeleton base class.
Epoch get_last_epoch() const
const ThreadLogBufferMeta & get_meta() const
Returns the state of this buffer.
static void advance(uint64_t buffer_size, uint64_t *target, uint64_t amount) __attribute__((always_inline))
Addition operator, considering wrapping around.
A log writer that writes out buffered logs to stable storages.
#define CXX11_FINAL
Used in public headers in place of "final" of C++11.
OffsetRange get_logs_to_write(Epoch written_epoch)
Returns begin/end offsets of logs in the given epoch.
Database engine object that holds all resources and provides APIs.
uint64_t offset_begin_
Where the new epoch starts.
A thread-buffer's epoch marker, which indicates where a thread switched an epoch. ...
void discard_current_xct_log()
Called when the current transaction aborts.
uint64_t get_offset_durable() const
This marks the position upto which the log writer durably wrote out to log files. ...
void assert_consistent() const
Only for Debug-assertion.
friend std::ostream & operator<<(std::ostream &o, const ThreadEpockMark &v)
#define CXX11_OVERRIDE
Used in public headers in place of "override" of C++11.
ErrorStack initialize_once() override
#define CXX11_FUNC_DELETE
Used in public headers in place of " = delete" of C++11.
uint16_t ThreadId
Typedef for a global ID of Thread (core), which is unique across NUMA nodes.
uint64_t get_offset_committed() const
This marks the position upto which transaction logs are committed by the thread.
static uint64_t distance(uint64_t buffer_size, uint64_t from, uint64_t to) __attribute__((always_inline))
Subtract operator, considering wrapping around.
void on_log_written(Epoch written_epoch)
Called when the logger wrote out all logs in the given epoch, advancing oldest_mark_index_.
ErrorStack uninitialize_once() override
uint64_t get_offset_tail() const
The current cursor to which next log will be written.
thread::ThreadId get_thread_id() const
#define UNLIKELY(x)
Hints that x is highly likely false.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
#define ALWAYS_INLINE
A function suffix to hint that the function should always be inlined.
char * reserve_new_log(uint16_t log_length) __attribute__((always_inline))
Reserves a space for a new (uncommitted) log entry at the tail.
ThreadEpockMark(Epoch old_epoch, Epoch new_epoch, uint64_t offset_begin)