drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
drizzled/lock.h
1/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2008 Sun Microsystems, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#pragma once
21
22#include <vector>
23#include <drizzled/thr_lock.h>
24#include <drizzled/locking/global.h>
25
26namespace drizzled {
27
28class DrizzleLock
29{
30public:
31 Table **getTable()
32 {
33 return &table[0];
34 }
35
36 THR_LOCK_DATA **getLocks()
37 {
38 return &locks[0];
39 }
40
41 size_t sizeTable() const
42 {
43 return table.size();
44 }
45
46 void resizeTable(size_t arg)
47 {
48 table.resize(arg);
49 }
50
51 size_t sizeLock() const
52 {
53 return lock_count;
54 }
55
56 void resetLock()
57 {
58 lock_count= 0;
59 }
60
61 void setLock(size_t arg)
62 {
63 lock_count= arg;
64 }
65
66 void reset(void);
67 void unlock(uint32_t count);
68
69 DrizzleLock(size_t table_count_arg)
70 {
71 table.resize(table_count_arg);
72 lock_count= table_count_arg * 2;
73 locks.resize(lock_count);
74 }
75
76private:
77 uint32_t lock_count;
78
79 std::vector<Table *> table;
80 std::vector<THR_LOCK_DATA *> locks;
81 std::vector<THR_LOCK_DATA *> copy_of;
82};
83
84/* lockTables() and open_table() flags bits */
85#define DRIZZLE_LOCK_IGNORE_GLOBAL_READ_LOCK 0x0001
86#define DRIZZLE_LOCK_IGNORE_FLUSH 0x0002
87#define DRIZZLE_LOCK_NOTIFY_IF_NEED_REOPEN 0x0004
88#define DRIZZLE_OPEN_TEMPORARY_ONLY 0x0008
89
90} /* namespace drizzled */
91
TODO: Rename this file - func.h is stupid.