1
/* Copyright (C) 2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#ifndef DLC_FIFOLIST_HPP
17
#define DLC_FIFOLIST_HPP
19
#include "DLFifoList.hpp"
22
// Adds "count" to DLFifoList
23
template <class T, class U = T>
24
class DLCFifoList : public DLFifoList<T, U> {
27
struct Head : public DLFifoList<T, U>::Head {
28
Head() : m_count(0) {}
33
DLCFifoList(ArrayPool<T> & thePool) :
34
DLFifoList<T, U>(thePool)
38
Uint32 count() const { return head.m_count; }
40
// Redefine methods which do add or remove
42
bool seize(Ptr<T>& ptr) {
43
if (DLFifoList<T, U>::seize(ptr)) {
50
bool seizeId(Ptr<T>& ptr, Uint32 i) {
51
if (DLFifoList<T, U>::seizeId(ptr)) {
58
void add(Ptr<T>& ptr) {
59
DLFifoList<T, U>::add(ptr);
63
void remove(Ptr<T>& ptr) {
64
DLFifoList<T, U>::remove(ptr);
68
void release(Uint32 i) {
69
DLFifoList<T, U>::release(i);
73
void release(Ptr<T>& ptr) {
74
DLFifoList<T, U>::release(ptr);
79
DLFifoList<T, U>::release();
83
DLCFifoList<T>& operator=(const DLCFifoList<T>& src){
84
assert(&this->thePool == &src.thePool);
85
this->head = src.head;
94
template <class T, class U = T>
95
class LocalDLCFifoList : public DLCFifoList<T, U> {
97
LocalDLCFifoList(ArrayPool<T> & thePool,
98
typename DLCFifoList<T, U>::Head &_src)
99
: DLCFifoList<T, U>(thePool), src(_src)
103
assert(src.in_use == false);
108
~LocalDLCFifoList() {
110
assert(src.in_use == true);
115
typename DLCFifoList<T, U>::Head & src;