Skip to content

Commit 65083ba

Browse files
committed
MDEV-17441 - InnoDB transition to C++11 atomics
Simplified mutex code. MutexDebug uses OSMutex instead of atomic operations now.
1 parent e2b585c commit 65083ba

File tree

11 files changed

+222
-522
lines changed

11 files changed

+222
-522
lines changed

storage/innobase/include/ib0mutex.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Created 2013-03-26 Sunny Bains.
3535
#include "sync0arr.h"
3636

3737
/** OS mutex for tracking lock/unlock for debugging */
38-
template <template <typename> class Policy = NoPolicy>
38+
template <template <typename> class Policy>
3939
struct OSTrackMutex {
4040

4141
typedef Policy<OSTrackMutex> MutexPolicy;
@@ -152,7 +152,7 @@ struct OSTrackMutex {
152152
#include <sys/syscall.h>
153153

154154
/** Mutex implementation that used the Linux futex. */
155-
template <template <typename> class Policy = NoPolicy>
155+
template <template <typename> class Policy>
156156
struct TTASFutexMutex {
157157

158158
typedef Policy<TTASFutexMutex> MutexPolicy;
@@ -264,7 +264,7 @@ struct TTASFutexMutex {
264264

265265
#endif /* HAVE_IB_LINUX_FUTEX */
266266

267-
template <template <typename> class Policy = NoPolicy>
267+
template <template <typename> class Policy>
268268
struct TTASMutex {
269269

270270
typedef Policy<TTASMutex> MutexPolicy;
@@ -364,7 +364,7 @@ struct TTASMutex {
364364
std::atomic<uint32_t> m_lock_word;
365365
};
366366

367-
template <template <typename> class Policy = NoPolicy>
367+
template <template <typename> class Policy>
368368
struct TTASEventMutex {
369369

370370
typedef Policy<TTASEventMutex> MutexPolicy;
@@ -534,7 +534,6 @@ with the Performance Schema instrumentation. */
534534
template <typename MutexImpl>
535535
struct PolicyMutex
536536
{
537-
typedef MutexImpl MutexType;
538537
typedef typename MutexImpl::MutexPolicy Policy;
539538

540539
PolicyMutex() UNIV_NOTHROW : m_impl()
@@ -565,7 +564,7 @@ struct PolicyMutex
565564
pfs_exit();
566565
#endif /* UNIV_PFS_MUTEX */
567566

568-
policy().release(m_impl);
567+
ut_d(policy().context.release(m_impl));
569568

570569
m_impl.exit();
571570
}
@@ -591,11 +590,11 @@ struct PolicyMutex
591590
locker = pfs_begin_lock(&state, name, line);
592591
#endif /* UNIV_PFS_MUTEX */
593592

594-
policy().enter(m_impl, name, line);
593+
ut_d(policy().context.enter(m_impl, name, line));
595594

596595
m_impl.enter(n_spins, n_delay, name, line);
597596

598-
policy().locked(m_impl, name, line);
597+
ut_d(policy().context.locked(m_impl, name, line));
599598
#ifdef UNIV_PFS_MUTEX
600599
pfs_end(locker, 0);
601600
#endif /* UNIV_PFS_MUTEX */
@@ -624,9 +623,9 @@ struct PolicyMutex
624623

625624
if (ret == 0) {
626625

627-
policy().enter(m_impl, name, line);
626+
ut_d(policy().context.enter(m_impl, name, line));
628627

629-
policy().locked(m_impl, name, line);
628+
ut_d(policy().context.locked(m_impl, name, line));
630629
}
631630

632631
#ifdef UNIV_PFS_MUTEX
@@ -640,7 +639,7 @@ struct PolicyMutex
640639
/** @return true if the thread owns the mutex. */
641640
bool is_owned() const UNIV_NOTHROW
642641
{
643-
return(policy().is_owned());
642+
return(policy().context.is_owned());
644643
}
645644
#endif /* UNIV_DEBUG */
646645

@@ -662,6 +661,7 @@ struct PolicyMutex
662661

663662
m_impl.init(id, filename, line);
664663
policy().init(m_impl, id, filename, line);
664+
ut_d(policy().context.init(id));
665665
}
666666

667667
/** Free resources (if any) */
@@ -672,6 +672,7 @@ struct PolicyMutex
672672
#endif /* UNIV_PFS_MUTEX */
673673
m_impl.destroy();
674674
policy().destroy();
675+
ut_d(policy().context.destroy());
675676
}
676677

677678
/** Required for os_event_t */

0 commit comments

Comments
 (0)