Drizzled Public API Documentation

lock.h

00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #pragma once
00021 
00022 #include <vector>
00023 #include <drizzled/thr_lock.h>
00024 #include <drizzled/locking/global.h>
00025 
00026 namespace drizzled
00027 {
00028 
00029 class Session;
00030 class Table;
00031 class TableList;
00032 
00033 class DrizzleLock
00034 {
00035 public:
00036   Table **getTable()
00037   {
00038     return &table[0];
00039   }
00040 
00041   THR_LOCK_DATA **getLocks()
00042   {
00043     return &locks[0];
00044   }
00045 
00046   size_t sizeTable() const
00047   {
00048     return table.size();
00049   }
00050 
00051   void resizeTable(size_t arg)
00052   {
00053     table.resize(arg);
00054   }
00055 
00056   size_t sizeLock() const
00057   {
00058     return lock_count;
00059   }
00060 
00061   void resetLock()
00062   {
00063     lock_count= 0;
00064   }
00065 
00066   void setLock(size_t arg)
00067   {
00068     lock_count= arg;
00069   }
00070 
00071   void reset(void);
00072   void unlock(uint32_t count);
00073 
00074   DrizzleLock(size_t table_count_arg)
00075   {
00076     table.resize(table_count_arg);
00077     lock_count= table_count_arg * 2;
00078     locks.resize(lock_count);
00079   }
00080 
00081 private:
00082   uint32_t lock_count;
00083 
00084   std::vector<Table *> table;
00085   std::vector<THR_LOCK_DATA *> locks;
00086   std::vector<THR_LOCK_DATA *> copy_of;
00087 };
00088 
00089 /* lockTables() and open_table() flags bits */
00090 #define DRIZZLE_LOCK_IGNORE_GLOBAL_READ_LOCK      0x0001
00091 #define DRIZZLE_LOCK_IGNORE_FLUSH                 0x0002
00092 #define DRIZZLE_LOCK_NOTIFY_IF_NEED_REOPEN        0x0004
00093 #define DRIZZLE_OPEN_TEMPORARY_ONLY               0x0008
00094 
00095 } /* namespace drizzled */
00096