Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Unified Diff: src/list.h

Issue 23479015: thread isolate in PreallocatedStorageAllocationPolicy (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: forgot explicit dtor Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/isolate.cc ('k') | src/string-stream.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/list.h
diff --git a/src/list.h b/src/list.h
index 0e4e35bb41b78b3ff5aa8b106ea284d1e4ded91c..d64256887b1d2822e9e571cc31ded21f87fa7d47 100644
--- a/src/list.h
+++ b/src/list.h
@@ -48,13 +48,15 @@ namespace internal {
// template <typename T,
// class AllocationPolicy = FreeStoreAllocationPolicy> class List;
template <typename T, class AllocationPolicy>
-class List {
+class List : private AllocationPolicy::Deleter {
public:
- explicit List(AllocationPolicy allocator = AllocationPolicy()) {
+ explicit List(AllocationPolicy allocator = AllocationPolicy())
+ : AllocationPolicy::Deleter(allocator) {
Initialize(0, allocator);
}
INLINE(explicit List(int capacity,
- AllocationPolicy allocator = AllocationPolicy())) {
+ AllocationPolicy allocator = AllocationPolicy()))
+ : AllocationPolicy::Deleter(allocator) {
Initialize(capacity, allocator);
}
INLINE(~List()) { DeleteData(data_); }
@@ -71,7 +73,7 @@ class List {
return allocator.New(static_cast<int>(size));
}
INLINE(void operator delete(void* p)) {
- AllocationPolicy::Delete(p);
+ AllocationPolicy::Deleter::Delete(p);
}
// Please the MSVC compiler. We should never have to execute this.
@@ -79,6 +81,13 @@ class List {
UNREACHABLE();
}
+ // Delete via the instance Deleter
+ static void Delete(List* p) {
+ if (p == NULL) return;
+ p->~List();
+ p->AllocationPolicy::Deleter::Delete(p);
+ }
+
// Returns a reference to the element at index i. This reference is
// not safe to use after operations that can change the list's
// backing store (e.g. Add).
@@ -179,7 +188,7 @@ class List {
return static_cast<T*>(allocator.New(n * sizeof(T)));
}
INLINE(void DeleteData(T* data)) {
- AllocationPolicy::Delete(data);
+ this->AllocationPolicy::Deleter::Delete(data);
}
// Increase the capacity of a full list, and add an element.
« no previous file with comments | « src/isolate.cc ('k') | src/string-stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698