Commit f401ba47 authored by Sergey Vojtovich's avatar Sergey Vojtovich

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

purge_sys_t::m_paused transition to Atomic_counter.

paused_latched() doesn't make much sense: in this particular case it is
as fast as atomic load. The sole caller has to reload it's value anyway,
due to rw_lock_x_lock(&purge_sys.latch) issuing acquire memory barrier.
parent 5cc6b48f
......@@ -150,7 +150,7 @@ class purge_sys_t
/** whether purge is enabled; protected by latch and my_atomic */
int32_t m_enabled;
/** number of pending stop() calls without resume() */
int32_t m_paused;
Atomic_counter<int32_t> m_paused;
public:
que_t* query; /*!< The query graph which will do the
parallelized purge operation */
......@@ -254,13 +254,7 @@ class purge_sys_t
}
/** @return whether the purge coordinator is paused */
bool paused()
{ return my_atomic_load32_explicit(&m_paused, MY_MEMORY_ORDER_RELAXED); }
/** @return whether the purge coordinator is paused */
bool paused_latched()
{
ut_ad(rw_lock_own_flagged(&latch, RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
return m_paused != 0;
}
{ return m_paused != 0; }
/** Enable purge at startup. Not protected by latch; the main thread
will wait for purge_sys.enabled() in srv_start() */
......
......@@ -2628,7 +2628,7 @@ srv_purge_coordinator_suspend(
rw_lock_x_lock(&purge_sys.latch);
stop = srv_shutdown_state == SRV_SHUTDOWN_NONE
&& purge_sys.paused_latched();
&& purge_sys.paused();
if (!stop) {
if (timeout
......
......@@ -1361,7 +1361,7 @@ void purge_sys_t::stop()
ut_ad(srv_n_purge_threads > 0);
if (0 == my_atomic_add32_explicit(&m_paused, 1, MY_MEMORY_ORDER_RELAXED))
if (m_paused++ == 0)
{
/* We need to wakeup the purge thread in case it is suspended, so
that it can acknowledge the state change. */
......@@ -1395,8 +1395,7 @@ void purge_sys_t::resume()
return;
}
int32_t paused= my_atomic_add32_explicit(&m_paused, -1,
MY_MEMORY_ORDER_RELAXED);
int32_t paused= m_paused--;
ut_a(paused);
if (paused == 1)
......
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