Commit 9e37537c authored by Sergey Vojtovich's avatar Sergey Vojtovich

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

Trivial fil_space_t::n_pending_ops transition. Since it is not
obvious which memory barriers are supposed to be issued, seq_cst
memory order was preserved.
parent e2d96e8a
......@@ -2297,7 +2297,7 @@ fil_check_pending_ops(const fil_space_t* space, ulint count)
return 0;
}
if (ulint n_pending_ops = my_atomic_loadlint(&space->n_pending_ops)) {
if (ulint n_pending_ops = space->n_pending_ops) {
if (count > 5000) {
ib::warn() << "Trying to close/delete/truncate"
......
......@@ -133,8 +133,8 @@ struct fil_space_t {
dropped. An example is change buffer merge.
The tablespace cannot be dropped while this is nonzero,
or while fil_node_t::n_pending is nonzero.
Protected by fil_system.mutex and my_atomic_loadlint() and friends. */
ulint n_pending_ops;
Protected by fil_system.mutex and std::atomic. */
std::atomic<ulint> n_pending_ops;
/** Number of pending block read or write operations
(when a write is imminent or a read has recently completed).
The tablespace object cannot be freed while this is nonzero,
......@@ -244,20 +244,11 @@ struct fil_space_t {
void close();
/** Acquire a tablespace reference. */
void acquire() { my_atomic_addlint(&n_pending_ops, 1); }
void acquire() { n_pending_ops++; }
/** Release a tablespace reference. */
void release()
{
ut_ad(referenced());
my_atomic_addlint(&n_pending_ops, ulint(-1));
}
void release() { ut_ad(referenced()); n_pending_ops--; }
/** @return whether references are being held */
bool referenced() { return my_atomic_loadlint(&n_pending_ops); }
/** @return whether references are being held */
bool referenced() const
{
return const_cast<fil_space_t*>(this)->referenced();
}
bool referenced() const { return n_pending_ops; }
/** Acquire a tablespace reference for I/O. */
void acquire_for_io() { n_pending_ios++; }
......
......@@ -1117,15 +1117,6 @@ enum rw_lock_flag_t {
#endif /* UNIV_INNOCHECKSUM */
static inline ulint my_atomic_addlint(ulint *A, ulint B)
{
#ifdef _WIN64
return ulint(my_atomic_add64((volatile int64*)A, B));
#else
return ulint(my_atomic_addlong(A, B));
#endif
}
static inline ulint my_atomic_loadlint(const ulint *A)
{
#ifdef _WIN64
......@@ -1135,15 +1126,6 @@ static inline ulint my_atomic_loadlint(const ulint *A)
#endif
}
static inline lint my_atomic_addlint(volatile lint *A, lint B)
{
#ifdef _WIN64
return my_atomic_add64((volatile int64*)A, B);
#else
return my_atomic_addlong(A, B);
#endif
}
static inline lint my_atomic_loadlint(const lint *A)
{
#ifdef _WIN64
......
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