Skip to content
Permalink
Browse files
MDEV-17441 - InnoDB transition to C++11 atomics
Replaced simple_atomic_counter with Atomic_counter.
  • Loading branch information
Sergey Vojtovich committed Dec 27, 2018
1 parent e976c7d commit dab38ce
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 27 deletions.
@@ -143,7 +143,8 @@ struct srv_stats_t
ulint_ctr_1_t n_lock_wait_count;

/** Number of threads currently waiting on database locks */
simple_atomic_counter<> n_lock_wait_current_count;
MY_ALIGNED(CACHE_LINE_SIZE) Atomic_counter<ulint>
n_lock_wait_current_count;

/** Number of rows read. */
ulint_ctr_64_t n_rows_read;
@@ -1184,28 +1184,4 @@ struct MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) simple_counter
/** The counter */
Type m_counter;
};

/** Simple atomic counter aligned to CACHE_LINE_SIZE
@tparam Type lint or ulint */
template <typename Type = ulint>
struct MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) simple_atomic_counter
{
/** Increment the counter */
Type inc() { return add(1); }
/** Decrement the counter */
Type dec() { return add(Type(~0)); }

/** Add to the counter
@param[in] i amount to be added
@return the value of the counter before adding */
Type add(Type i) { return my_atomic_addlint(&m_counter, i); }

/** @return the value of the counter (non-atomic access)! */
operator Type() const { return m_counter; }

private:
/** The counter */
Type m_counter;
};

#endif /* sync0types_h */
@@ -285,7 +285,7 @@ lock_wait_suspend_thread(

if (thr->lock_state == QUE_THR_LOCK_ROW) {
srv_stats.n_lock_wait_count.inc();
srv_stats.n_lock_wait_current_count.inc();
srv_stats.n_lock_wait_current_count++;

if (ut_usectime(&sec, &ms) == -1) {
start_time = -1;
@@ -398,7 +398,7 @@ lock_wait_suspend_thread(
thd_storage_lock_wait(trx->mysql_thd, diff_time);
}

srv_stats.n_lock_wait_current_count.dec();
srv_stats.n_lock_wait_current_count--;

DBUG_EXECUTE_IF("lock_instrument_slow_query_log",
os_thread_sleep(1000););

0 comments on commit dab38ce

Please sign in to comment.