gem5
v23.0.0.0
Toggle main menu visibility
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
x
Enumerations
_
a
b
c
d
e
f
g
h
i
k
l
m
o
p
q
r
s
t
v
x
Enumerator
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
y
Enumerations
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
w
Enumerator
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Related Symbols
:
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
s
t
v
Variables
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
Typedefs
a
b
c
d
g
h
i
l
m
r
s
t
u
w
Enumerations
b
h
i
o
p
Enumerator
h
i
o
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
systemc
tests
tlm
multi_sockets
extensionPool.h
Go to the documentation of this file.
1
/*****************************************************************************
2
3
Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4
more contributor license agreements. See the NOTICE file distributed
5
with this work for additional information regarding copyright ownership.
6
Accellera licenses this file to you under the Apache License, Version 2.0
7
(the "License"); you may not use this file except in compliance with the
8
License. You may obtain a copy of the License at
9
10
http://www.apache.org/licenses/LICENSE-2.0
11
12
Unless required by applicable law or agreed to in writing, software
13
distributed under the License is distributed on an "AS IS" BASIS,
14
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15
implied. See the License for the specific language governing
16
permissions and limitations under the License.
17
18
*****************************************************************************/
19
20
#ifndef __EXTENSION_POOL_H__
21
#define __EXTENSION_POOL_H__
22
23
template
<
class
T>
24
class
ExtensionPool
{
25
struct
entry
{
26
public
:
27
entry
(T* content){
28
that
=content;
29
next
=NULL;
30
}
31
T*
that
;
32
entry
*
next
;
33
};
34
35
public
:
36
ExtensionPool
(
int
size):
used
(NULL){
37
unused
=
new
entry
(
new
T());
//create first one
38
mine
.push_back(
unused
->
that
);
39
for
(
int
i=0; i<size-1; i++){
40
entry
* e=
new
entry
(
new
T());
41
e->next=
unused
;
42
unused
=e;
43
mine
.push_back(
unused
->
that
);
44
}
45
}
46
47
~ExtensionPool
(){
48
//delete all T* that belong to this pool
49
for
(
unsigned
int
i=0; i<
mine
.size(); i++){
50
delete
mine
[i];
51
}
52
53
//delete all unused elements
54
while
(
unused
){
55
entry
* e=
unused
;
56
unused
=
unused
->
next
;
57
delete
e;
58
}
59
60
//delete all used elements
61
while
(
used
){
62
entry
* e=
used
;
63
used
=
used
->
next
;
64
delete
e;
65
}
66
}
67
68
bool
is_from
(T* cont){
//slow!!!
69
for
(
int
i=0; i<
mine
.size(); i++){
70
if
(
mine
[i]==cont)
return
true
;
71
}
72
return
false
;
73
}
74
75
T*
construct
(){
76
entry
* e;
77
if
(
unused
==NULL){
78
e=
new
entry
(
new
T());
79
mine
.push_back(e->that);
80
}
81
else
{
82
e=
unused
;
83
unused
=
unused
->
next
;
84
}
85
e->next=
used
;
86
used
=e;
87
return
used
->
that
;
//if all elements of pool are used, just create a new one and go on
88
}
89
90
void
free
(T* cont){
91
sc_assert
(
used
);
92
entry
* e=
used
;
93
used
=e->next;
94
e->that=cont;
95
e->next=
unused
;
96
unused
=e;
97
}
98
99
private
:
100
entry
*
unused
;
101
entry
*
used
;
102
std::vector<T*>
mine
;
//just for clean up and is_from
103
};
104
105
#endif
106
ExtensionPool
Definition
extensionPool.h:24
ExtensionPool::used
entry * used
Definition
extensionPool.h:101
ExtensionPool::mine
std::vector< T * > mine
Definition
extensionPool.h:102
ExtensionPool::unused
entry * unused
Definition
extensionPool.h:100
ExtensionPool::construct
T * construct()
Definition
extensionPool.h:75
ExtensionPool::~ExtensionPool
~ExtensionPool()
Definition
extensionPool.h:47
ExtensionPool::ExtensionPool
ExtensionPool(int size)
Definition
extensionPool.h:36
ExtensionPool::is_from
bool is_from(T *cont)
Definition
extensionPool.h:68
ExtensionPool::free
void free(T *cont)
Definition
extensionPool.h:90
std::vector
STL vector class.
Definition
stl.hh:37
sc_assert
#define sc_assert(expr)
Definition
sc_report_handler.hh:135
ExtensionPool::entry
Definition
extensionPool.h:25
ExtensionPool::entry::entry
entry(T *content)
Definition
extensionPool.h:27
ExtensionPool::entry::that
T * that
Definition
extensionPool.h:31
ExtensionPool::entry::next
entry * next
Definition
extensionPool.h:32
Generated on Mon Jul 10 2023 14:24:35 for gem5 by
doxygen
1.9.7