Drizzled Public API Documentation

lock0iter.cc
00001 /*****************************************************************************
00002 
00003 Copyright (C) 2007, 2009, Innobase Oy. All Rights Reserved.
00004 
00005 This program is free software; you can redistribute it and/or modify it under
00006 the terms of the GNU General Public License as published by the Free Software
00007 Foundation; version 2 of the License.
00008 
00009 This program is distributed in the hope that it will be useful, but WITHOUT
00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
00012 
00013 You should have received a copy of the GNU General Public License along with
00014 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
00015 St, Fifth Floor, Boston, MA 02110-1301 USA
00016 
00017 *****************************************************************************/
00018 
00019 /**************************************************/
00027 #define LOCK_MODULE_IMPLEMENTATION
00028 
00029 #include "univ.i"
00030 #include "lock0iter.h"
00031 #include "lock0lock.h"
00032 #include "lock0priv.h"
00033 #include "ut0dbg.h"
00034 #include "ut0lst.h"
00035 #ifdef UNIV_DEBUG
00036 # include "srv0srv.h" /* kernel_mutex */
00037 #endif /* UNIV_DEBUG */
00038 
00039 /*******************************************************************/
00048 UNIV_INTERN
00049 void
00050 lock_queue_iterator_reset(
00051 /*======================*/
00052   lock_queue_iterator_t*  iter, 
00053   const lock_t*   lock, 
00054   ulint     bit_no) 
00056 {
00057   ut_ad(mutex_own(&kernel_mutex));
00058 
00059   iter->current_lock = lock;
00060 
00061   if (bit_no != ULINT_UNDEFINED) {
00062 
00063     iter->bit_no = bit_no;
00064   } else {
00065 
00066     switch (lock_get_type_low(lock)) {
00067     case LOCK_TABLE:
00068       iter->bit_no = ULINT_UNDEFINED;
00069       break;
00070     case LOCK_REC:
00071       iter->bit_no = lock_rec_find_set_bit(lock);
00072       ut_a(iter->bit_no != ULINT_UNDEFINED);
00073       break;
00074     default:
00075       ut_error;
00076     }
00077   }
00078 }
00079 
00080 /*******************************************************************/
00085 UNIV_INTERN
00086 const lock_t*
00087 lock_queue_iterator_get_prev(
00088 /*=========================*/
00089   lock_queue_iterator_t*  iter) 
00090 {
00091   const lock_t* prev_lock;
00092 
00093   ut_ad(mutex_own(&kernel_mutex));
00094 
00095   switch (lock_get_type_low(iter->current_lock)) {
00096   case LOCK_REC:
00097     prev_lock = lock_rec_get_prev(
00098       iter->current_lock, iter->bit_no);
00099     break;
00100   case LOCK_TABLE:
00101     prev_lock = UT_LIST_GET_PREV(
00102       un_member.tab_lock.locks, iter->current_lock);
00103     break;
00104   default:
00105     ut_error;
00106   }
00107 
00108   if (prev_lock != NULL) {
00109 
00110     iter->current_lock = prev_lock;
00111   }
00112 
00113   return(prev_lock);
00114 }