23 #include <sys/types.h>
28 #include <drizzled/identifier.h>
29 #include <drizzled/sql_base.h>
30 #include <drizzled/set_var.h>
31 #include <drizzled/table/cache.h>
32 #include <drizzled/table/unused.h>
36 extern uint64_t table_cache_size;
40 UnusedTables &getUnused(
void)
42 static UnusedTables unused_tables;
47 void UnusedTables::cull()
50 while (table::getCache().size() > 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());
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)
83 if (table == getTable())
85 setTable(getTable()->getNext());
86 if (table == getTable())
93 void UnusedTables::relink(Concurrent *table)
95 if (table != getTable())
99 table->setNext(getTable());
100 table->setPrev(getTable()->getPrev());
101 getTable()->getPrev()->setNext(table);
102 getTable()->setPrev(table);
107 void UnusedTables::clear()
110 remove_table(getTable());
TODO: Rename this file - func.h is stupid.