summaryrefslogtreecommitdiff
path: root/storage/innobase/include/hash0hash.ic
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/include/hash0hash.ic')
-rw-r--r--storage/innobase/include/hash0hash.ic70
1 files changed, 56 insertions, 14 deletions
diff --git a/storage/innobase/include/hash0hash.ic b/storage/innobase/include/hash0hash.ic
index 0b437894e2e..1e5474601d5 100644
--- a/storage/innobase/include/hash0hash.ic
+++ b/storage/innobase/include/hash0hash.ic
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1997, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1997, 2009, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
@@ -87,20 +87,21 @@ hash_calc_hash(
#ifndef UNIV_HOTBACKUP
/************************************************************//**
-Gets the mutex index for a fold value in a hash table.
-@return mutex number */
+Gets the sync object index for a fold value in a hash table.
+@return index */
UNIV_INLINE
ulint
-hash_get_mutex_no(
-/*==============*/
+hash_get_sync_obj_index(
+/*====================*/
hash_table_t* table, /*!< in: hash table */
ulint fold) /*!< in: fold */
{
ut_ad(table);
ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
- ut_ad(ut_is_2pow(table->n_mutexes));
+ ut_ad(table->type != HASH_TABLE_SYNC_NONE);
+ ut_ad(ut_is_2pow(table->n_sync_obj));
return(ut_2pow_remainder(hash_calc_hash(fold, table),
- table->n_mutexes));
+ table->n_sync_obj));
}
/************************************************************//**
@@ -115,7 +116,8 @@ hash_get_nth_heap(
{
ut_ad(table);
ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
- ut_ad(i < table->n_mutexes);
+ ut_ad(table->type != HASH_TABLE_SYNC_NONE);
+ ut_ad(i < table->n_sync_obj);
return(table->heaps[i]);
}
@@ -139,7 +141,7 @@ hash_get_heap(
return(table->heap);
}
- i = hash_get_mutex_no(table, fold);
+ i = hash_get_sync_obj_index(table, fold);
return(hash_get_nth_heap(table, i));
}
@@ -156,9 +158,10 @@ hash_get_nth_mutex(
{
ut_ad(table);
ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
- ut_ad(i < table->n_mutexes);
+ ut_ad(table->type == HASH_TABLE_SYNC_MUTEX);
+ ut_ad(i < table->n_sync_obj);
- return(table->mutexes + i);
+ return(table->sync_obj.mutexes + i);
}
/************************************************************//**
@@ -176,8 +179,47 @@ hash_get_mutex(
ut_ad(table);
ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
- i = hash_get_mutex_no(table, fold);
+ i = hash_get_sync_obj_index(table, fold);
return(hash_get_nth_mutex(table, i));
}
+
+/************************************************************//**
+Gets the nth rw_lock in a hash table.
+@return rw_lock */
+UNIV_INLINE
+rw_lock_t*
+hash_get_nth_lock(
+/*==============*/
+ hash_table_t* table, /*!< in: hash table */
+ ulint i) /*!< in: index of the rw_lock */
+{
+ ut_ad(table);
+ ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
+ ut_ad(table->type == HASH_TABLE_SYNC_RW_LOCK);
+ ut_ad(i < table->n_sync_obj);
+
+ return(table->sync_obj.rw_locks + i);
+}
+
+/************************************************************//**
+Gets the rw_lock for a fold value in a hash table.
+@return rw_lock */
+UNIV_INLINE
+rw_lock_t*
+hash_get_lock(
+/*==========*/
+ hash_table_t* table, /*!< in: hash table */
+ ulint fold) /*!< in: fold */
+{
+ ulint i;
+
+ ut_ad(table);
+ ut_ad(table->type == HASH_TABLE_SYNC_RW_LOCK);
+ ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
+
+ i = hash_get_sync_obj_index(table, fold);
+
+ return(hash_get_nth_lock(table, i));
+}
#endif /* !UNIV_HOTBACKUP */