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