6565lock_get_size (void );
6666/* ===============*/
6767/* ********************************************************************/ /* *
68- Creates the lock system at database start. */
69- void
70- lock_sys_create (
71- /* ============*/
72- ulint n_cells);/* !< in: number of slots in lock hash table */
73- /* * Resize the lock hash table.
74- @param[in] n_cells number of slots in lock hash table */
75- void
76- lock_sys_resize (
77- ulint n_cells);
78-
79- /* ********************************************************************/ /* *
80- Closes the lock system at database shutdown. */
81- void
82- lock_sys_close (void );
83- /* ================*/
84- /* ********************************************************************/ /* *
8568Gets the heap_no of the smallest user record on a page.
8669@return heap_no of smallest user record, or PAGE_HEAP_NO_SUPREMUM */
8770UNIV_INLINE
@@ -605,7 +588,7 @@ lock_print_info_all_transactions(
605588Return approximate number or record locks (bits set in the bitmap) for
606589this transaction. Since delete-marked records may be removed, the
607590record count will not be precise.
608- The caller must be holding lock_sys-> mutex. */
591+ The caller must be holding lock_sys. mutex. */
609592ulint
610593lock_number_of_rows_locked (
611594/* =======================*/
@@ -614,7 +597,7 @@ lock_number_of_rows_locked(
614597
615598/* ********************************************************************/ /* *
616599Return the number of table locks for a transaction.
617- The caller must be holding lock_sys-> mutex. */
600+ The caller must be holding lock_sys. mutex. */
618601ulint
619602lock_number_of_tables_locked (
620603/* =========================*/
@@ -897,11 +880,12 @@ struct lock_op_t{
897880typedef ib_mutex_t LockMutex;
898881
899882/* * The lock system struct */
900- struct lock_sys_t {
901- char pad1[CACHE_LINE_SIZE];/* !< padding to prevent other
902- memory update hotspots from
903- residing on the same memory
904- cache line */
883+ class lock_sys_t
884+ {
885+ bool m_initialised;
886+
887+ public:
888+ MY_ALIGNED (CACHE_LINE_SIZE)
905889LockMutex mutex;/* !< Mutex protecting the
906890locks */
907891hash_table_t * rec_hash;/* !< hash table of the record
@@ -911,13 +895,13 @@ struct lock_sys_t{
911895hash_table_t * prdt_page_hash;/* !< hash table of the page
912896lock */
913897
914- char pad2[ CACHE_LINE_SIZE]; /* !< Padding */
898+ MY_ALIGNED ( CACHE_LINE_SIZE)
915899LockMutex wait_mutex;/* !< Mutex protecting the
916900next two fields */
917901srv_slot_t * waiting_threads;/* !< Array of user threads
918902suspended while waiting for
919903locks within InnoDB, protected
920- by the lock_sys-> wait_mutex;
904+ by the lock_sys. wait_mutex;
921905os_event_set() and
922906os_event_reset() on
923907waiting_threads[]->event
@@ -926,7 +910,7 @@ struct lock_sys_t{
926910srv_slot_t * last_slot;/* !< highest slot ever used
927911in the waiting_threads array,
928912protected by
929- lock_sys-> wait_mutex */
913+ lock_sys. wait_mutex */
930914
931915ulint n_lock_max_wait_time;/* !< Max wait time */
932916
@@ -938,6 +922,38 @@ struct lock_sys_t{
938922
939923bool timeout_thread_active;/* !< True if the timeout thread
940924is running */
925+
926+
927+ /* *
928+ Constructor.
929+
930+ Some members may require late initialisation, thus we just mark object as
931+ uninitialised. Real initialisation happens in create().
932+ */
933+ lock_sys_t (): m_initialised(false ) {}
934+
935+
936+ bool is_initialised () { return m_initialised; }
937+
938+
939+ /* *
940+ Creates the lock system at database start.
941+
942+ @param[in] n_cells number of slots in lock hash table
943+ */
944+ void create (ulint n_cells);
945+
946+
947+ /* *
948+ Resize the lock hash table.
949+
950+ @param[in] n_cells number of slots in lock hash table
951+ */
952+ void resize (ulint n_cells);
953+
954+
955+ /* * Closes the lock system at database shutdown. */
956+ void close ();
941957};
942958
943959/* ************************************************************/ /* *
@@ -982,36 +998,36 @@ lock_rec_trx_wait(
982998ulint type);
983999
9841000/* * The lock system */
985- extern lock_sys_t * lock_sys;
1001+ extern lock_sys_t lock_sys;
9861002
987- /* * Test if lock_sys-> mutex can be acquired without waiting. */
1003+ /* * Test if lock_sys. mutex can be acquired without waiting. */
9881004#define lock_mutex_enter_nowait () \
989- (lock_sys-> mutex.trylock(__FILE__, __LINE__))
1005+ (lock_sys. mutex.trylock(__FILE__, __LINE__))
9901006
991- /* * Test if lock_sys-> mutex is owned. */
992- #define lock_mutex_own () (lock_sys-> mutex.is_owned())
1007+ /* * Test if lock_sys. mutex is owned. */
1008+ #define lock_mutex_own () (lock_sys. mutex.is_owned())
9931009
994- /* * Acquire the lock_sys-> mutex. */
1010+ /* * Acquire the lock_sys. mutex. */
9951011#define lock_mutex_enter () do { \
996- mutex_enter (&lock_sys-> mutex ); \
1012+ mutex_enter (&lock_sys. mutex ); \
9971013} while (0 )
9981014
999- /* * Release the lock_sys-> mutex. */
1015+ /* * Release the lock_sys. mutex. */
10001016#define lock_mutex_exit () do { \
1001- lock_sys-> mutex .exit (); \
1017+ lock_sys. mutex .exit (); \
10021018} while (0 )
10031019
1004- /* * Test if lock_sys-> wait_mutex is owned. */
1005- #define lock_wait_mutex_own () (lock_sys-> wait_mutex.is_owned())
1020+ /* * Test if lock_sys. wait_mutex is owned. */
1021+ #define lock_wait_mutex_own () (lock_sys. wait_mutex.is_owned())
10061022
1007- /* * Acquire the lock_sys-> wait_mutex. */
1023+ /* * Acquire the lock_sys. wait_mutex. */
10081024#define lock_wait_mutex_enter () do { \
1009- mutex_enter (&lock_sys-> wait_mutex ); \
1025+ mutex_enter (&lock_sys. wait_mutex ); \
10101026} while (0 )
10111027
1012- /* * Release the lock_sys-> wait_mutex. */
1028+ /* * Release the lock_sys. wait_mutex. */
10131029#define lock_wait_mutex_exit () do { \
1014- lock_sys-> wait_mutex .exit (); \
1030+ lock_sys. wait_mutex .exit (); \
10151031} while (0 )
10161032
10171033#ifdef WITH_WSREP
0 commit comments