1 /* src/toolbox/list.hpp - linked list
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
37 #include "threads/mutex.hpp"
43 * List implementation with a Mutex.
45 template<class T> class List : protected std::list<T> {
52 void lock () { _mutex.lock(); }
53 void unlock() { _mutex.unlock(); }
55 // make iterator of std::list visible
56 using std::list<T>::iterator;
57 using std::list<T>::reverse_iterator;
59 // make functions of std::list visible
60 using std::list<T>::back;
61 using std::list<T>::begin;
62 using std::list<T>::clear;
63 using std::list<T>::empty;
64 using std::list<T>::end;
65 using std::list<T>::front;
66 using std::list<T>::push_back;
67 using std::list<T>::push_front;
68 using std::list<T>::rbegin;
69 using std::list<T>::remove;
70 using std::list<T>::rend;
71 using std::list<T>::size;
75 // Required by DumpList.
76 #include "mm/dumpmemory.hpp"
80 * List implementation with dump memory.
82 template<class T> class DumpList : protected std::list<T, DumpMemoryAllocator<T> > {
84 virtual ~DumpList() {}
86 // make iterator of std::list visible
87 using std::list<T, DumpMemoryAllocator<T> >::iterator;
88 using std::list<T, DumpMemoryAllocator<T> >::reverse_iterator;
90 // make functions of std::list visible
91 using std::list<T, DumpMemoryAllocator<T> >::back;
92 using std::list<T, DumpMemoryAllocator<T> >::begin;
93 using std::list<T, DumpMemoryAllocator<T> >::clear;
94 using std::list<T, DumpMemoryAllocator<T> >::empty;
95 using std::list<T, DumpMemoryAllocator<T> >::end;
96 using std::list<T, DumpMemoryAllocator<T> >::front;
97 using std::list<T, DumpMemoryAllocator<T> >::push_back;
98 using std::list<T, DumpMemoryAllocator<T> >::push_front;
99 using std::list<T, DumpMemoryAllocator<T> >::rbegin;
100 using std::list<T, DumpMemoryAllocator<T> >::remove;
101 using std::list<T, DumpMemoryAllocator<T> >::rend;
102 using std::list<T, DumpMemoryAllocator<T> >::size;
104 void* operator new(size_t size) {
105 return DumpMemory::allocate(size);
108 void operator delete(void* p) {}
113 typedef struct List List;
114 typedef struct DumpList DumpList;
122 * These are local overrides for various environment variables in Emacs.
123 * Please do not remove this and leave it at the end of the file, where
124 * Emacs will automagically detect them.
125 * ---------------------------------------------------------------------
128 * indent-tabs-mode: t