diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2018-12-29 00:04:55 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2018-12-29 14:09:33 +0400 |
commit | 9e37537c4e9c8b5cc5aff75b6e891be4cd877573 (patch) | |
tree | 6594cf12c914df309db289a739da7ed35cd27271 | |
parent | e2d96e8a16704c02248c9039028f9de17c887846 (diff) | |
download | mariadb-git-9e37537c4e9c8b5cc5aff75b6e891be4cd877573.tar.gz |
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.
-rw-r--r-- | storage/innobase/fil/fil0fil.cc | 2 | ||||
-rw-r--r-- | storage/innobase/include/fil0fil.h | 19 | ||||
-rw-r--r-- | storage/innobase/include/sync0types.h | 18 |
3 files changed, 6 insertions, 33 deletions
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 34a98d825a1..ffd82ca9415 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -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" diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index f6a597057a3..bce9516b11d 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -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++; } diff --git a/storage/innobase/include/sync0types.h b/storage/innobase/include/sync0types.h index 8f7ac82974b..e7d1326d6a5 100644 --- a/storage/innobase/include/sync0types.h +++ b/storage/innobase/include/sync0types.h @@ -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 |