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 class DrizzleLock
00029 {
00030 public:
00031   Table **getTable()
00032   {
00033     return &table[0];
00034   }
00035 
00036   THR_LOCK_DATA **getLocks()
00037   {
00038     return &locks[0];
00039   }
00040 
00041   size_t sizeTable() const
00042   {
00043     return table.size();
00044   }
00045 
00046   void resizeTable(size_t arg)
00047   {
00048     table.resize(arg);
00049   }
00050 
00051   size_t sizeLock() const
00052   {
00053     return lock_count;
00054   }
00055 
00056   void resetLock()
00057   {
00058     lock_count= 0;
00059   }
00060 
00061   void setLock(size_t arg)
00062   {
00063     lock_count= arg;
00064   }
00065 
00066   void reset(void);
00067   void unlock(uint32_t count);
00068 
00069   DrizzleLock(size_t table_count_arg)
00070   {
00071     table.resize(table_count_arg);
00072     lock_count= table_count_arg * 2;
00073     locks.resize(lock_count);
00074   }
00075 
00076 private:
00077   uint32_t lock_count;
00078 
00079   std::vector<Table *> table;
00080   std::vector<THR_LOCK_DATA *> locks;
00081   std::vector<THR_LOCK_DATA *> copy_of;
00082 };
00083 
00084 /* lockTables() and open_table() flags bits */
00085 #define DRIZZLE_LOCK_IGNORE_GLOBAL_READ_LOCK      0x0001
00086 #define DRIZZLE_LOCK_IGNORE_FLUSH                 0x0002
00087 #define DRIZZLE_LOCK_NOTIFY_IF_NEED_REOPEN        0x0004
00088 #define DRIZZLE_OPEN_TEMPORARY_ONLY               0x0008
00089 
00090 } /* namespace drizzled */
00091