1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Brian Aker
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; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
#include <sys/types.h>
28
#include "drizzled/identifier/table.h"
29
#include "drizzled/sql_base.h"
30
#include "drizzled/set_var.h"
32
#include "drizzled/table/unused.h"
40
UnusedTables &getUnused(void)
42
static UnusedTables unused_tables;
47
void UnusedTables::cull()
49
/* Free cache if too big */
50
while (cached_open_tables() > table_cache_size && getTable())
51
remove_table(getTable());
54
void UnusedTables::cullByVersion()
56
while (getTable() && not getTable()->getShare()->getVersion())
57
remove_table(getTable());
60
void UnusedTables::link(Concurrent *table)
64
table->setNext(getTable()); /* Link in last */
65
table->setPrev(getTable()->getPrev());
66
getTable()->setPrev(table);
67
table->getPrev()->setNext(table);
71
table->setPrev(setTable(table));
72
table->setNext(table->getPrev());
73
assert(table->getNext() == table && table->getPrev() == table);
78
void UnusedTables::unlink(Concurrent *table)
82
/* Unlink the table from "unused_tables" list. */
83
if (table == getTable())
85
setTable(getTable()->getNext()); // Remove from link
86
if (table == getTable())
91
/* move table first in unused links */
93
void UnusedTables::relink(Concurrent *table)
95
if (table != getTable())
99
table->setNext(getTable()); /* Link in unused tables */
100
table->setPrev(getTable()->getPrev());
101
getTable()->getPrev()->setNext(table);
102
getTable()->setPrev(table);
107
void UnusedTables::clear()
110
remove_table(getTable());
113
} /* namespace table */
114
} /* namespace drizzled */