diff options
Diffstat (limited to 'source/tanya/memory/package.d')
| -rw-r--r-- | source/tanya/memory/package.d | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/source/tanya/memory/package.d b/source/tanya/memory/package.d index 352476f..f48fbd1 100644 --- a/source/tanya/memory/package.d +++ b/source/tanya/memory/package.d @@ -15,6 +15,7 @@ import std.algorithm.iteration; public import std.experimental.allocator : make; import std.traits; public import tanya.memory.allocator; +import tanya.memory.mmappool; /** * The mixin generates common methods for classes and structs using @@ -88,7 +89,6 @@ shared Allocator allocator; shared static this() nothrow @trusted @nogc { - import tanya.memory.mmappool; allocator = MmapPool.instance; } @@ -112,6 +112,17 @@ body .allocator = allocator; } +private nothrow @nogc unittest +{ + import tanya.memory.mallocator; + + auto oldAllocator = defaultAllocator; + defaultAllocator = Mallocator.instance; + assert(defaultAllocator is Mallocator.instance); + + defaultAllocator = oldAllocator; +} + /** * Returns the size in bytes of the state that needs to be allocated to hold an * object of type $(D_PARAM T). @@ -307,3 +318,19 @@ private unittest defaultAllocator.dispose(p); } + +// Works with interfaces. +private unittest +{ + interface I + { + } + class C : I + { + } + auto c = defaultAllocator.make!C(); + I i = c; + + defaultAllocator.dispose(i); + defaultAllocator.dispose(i); +} |
