Commit dab38ce0 authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-17441 - InnoDB transition to C++11 atomics

Replaced simple_atomic_counter with Atomic_counter.
parent e976c7db
...@@ -143,7 +143,8 @@ struct srv_stats_t ...@@ -143,7 +143,8 @@ struct srv_stats_t
ulint_ctr_1_t n_lock_wait_count; ulint_ctr_1_t n_lock_wait_count;
/** Number of threads currently waiting on database locks */ /** 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. */ /** Number of rows read. */
ulint_ctr_64_t n_rows_read; ulint_ctr_64_t n_rows_read;
......
...@@ -1184,28 +1184,4 @@ struct MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) simple_counter ...@@ -1184,28 +1184,4 @@ struct MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) simple_counter
/** The counter */ /** The counter */
Type m_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 */ #endif /* sync0types_h */
...@@ -285,7 +285,7 @@ lock_wait_suspend_thread( ...@@ -285,7 +285,7 @@ lock_wait_suspend_thread(
if (thr->lock_state == QUE_THR_LOCK_ROW) { if (thr->lock_state == QUE_THR_LOCK_ROW) {
srv_stats.n_lock_wait_count.inc(); 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) { if (ut_usectime(&sec, &ms) == -1) {
start_time = -1; start_time = -1;
...@@ -398,7 +398,7 @@ lock_wait_suspend_thread( ...@@ -398,7 +398,7 @@ lock_wait_suspend_thread(
thd_storage_lock_wait(trx->mysql_thd, diff_time); 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", DBUG_EXECUTE_IF("lock_instrument_slow_query_log",
os_thread_sleep(1000);); os_thread_sleep(1000););
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment