From ad46afb10bca80086b11b998bf4c992dc96f577e Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 22 Mar 2019 08:18:01 +0100 Subject: [PATCH] Move memory/package.d into memory.allocator --- .travis.yml | 1 - README.md | 10 +- appveyor.yml | 6 - middle/tanya/memory/allocator.d | 416 ++++++++++++++++++++++++++++ middle/tanya/memory/lifetime.d | 309 +-------------------- middle/tanya/memory/op.d | 46 +-- middle/tanya/memory/package.d | 112 -------- middle/tanya/memory/smartref.d | 3 +- source/tanya/async/event/epoll.d | 4 +- source/tanya/async/event/iocp.d | 4 +- source/tanya/async/event/kqueue.d | 4 +- source/tanya/async/event/selector.d | 4 +- source/tanya/async/iocp.d | 2 +- source/tanya/async/loop.d | 4 +- source/tanya/async/package.d | 2 +- source/tanya/async/protocol.d | 2 +- source/tanya/async/transport.d | 2 +- source/tanya/async/watcher.d | 4 +- source/tanya/container/array.d | 3 +- source/tanya/container/buffer.d | 2 +- source/tanya/container/hashtable.d | 3 +- source/tanya/container/list.d | 3 +- source/tanya/container/set.d | 3 +- source/tanya/container/string.d | 3 +- source/tanya/conv.d | 10 +- source/tanya/exception.d | 4 +- source/tanya/format.d | 18 +- source/tanya/math/mp.d | 3 +- source/tanya/math/random.d | 2 +- source/tanya/net/uri.d | 2 +- source/tanya/network/package.d | 2 +- source/tanya/network/socket.d | 4 +- source/tanya/typecons.d | 6 +- test/tanya/test/assertion.d | 4 +- test/tanya/test/package.d | 2 +- test/tanya/test/stub.d | 2 +- tests/tanya/async/tests/loop.d | 2 +- tests/tanya/container/tests/array.d | 2 +- tests/tanya/container/tests/set.d | 2 +- tests/tanya/math/tests/random.d | 2 +- tests/tanya/memory/tests/lifetime.d | 3 +- tests/tanya/memory/tests/smartref.d | 2 +- tests/tanya/tests/format.d | 2 +- 43 files changed, 489 insertions(+), 537 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5ac104b..1871bd1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ language: d d: - dmd-2.085.0 -- dmd-2.084.1 - dmd-2.082.1 env: diff --git a/README.md b/README.md index a1b7ece..5232a57 100644 --- a/README.md +++ b/README.md @@ -172,12 +172,10 @@ parameter is used) ### Supported compilers -| DMD | GCC | -|:-------:|:---------------:| -| 2.085.0 | gdc-8 (2.081.2) | -| 2.084.1 | gdc-7 (2.081.2) | -| 2.083.1 | | -| 2.082.1 | | +| DMD | GCC | +|:-----------------:|:---------------:| +| 2.081.2 — 2.085.0 | gdc-8 (2.081.2) | +| | gdc-7 (2.081.2) | ### Release management diff --git a/appveyor.yml b/appveyor.yml index 2b15380..1437042 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,12 +9,6 @@ environment: - DC: dmd DVersion: 2.085.0 arch: x86 - - DC: dmd - DVersion: 2.084.1 - arch: x64 - - DC: dmd - DVersion: 2.084.1 - arch: x86 - DC: dmd DVersion: 2.082.1 arch: x64 diff --git a/middle/tanya/memory/allocator.d b/middle/tanya/memory/allocator.d index bf356af..96f3a29 100644 --- a/middle/tanya/memory/allocator.d +++ b/middle/tanya/memory/allocator.d @@ -17,6 +17,9 @@ */ module tanya.memory.allocator; +import tanya.memory.lifetime; +import tanya.meta.trait; + /** * Abstract class implementing a basic allocator. */ @@ -79,3 +82,416 @@ package template GetPureInstance(T : Allocator) alias GetPureInstance = shared(T) function() pure nothrow @nogc; } + +/** + * The mixin generates common methods for classes and structs using + * allocators. It provides a protected member, constructor and a read-only property, + * that checks if an allocator was already set and sets it to the default + * one, if not (useful for structs which don't have a default constructor). + */ +mixin template DefaultAllocator() +{ + /// Allocator. + protected shared Allocator allocator_; + + /** + * Params: + * allocator = The allocator should be used. + * + * Precondition: $(D_INLINECODE allocator_ !is null) + */ + this(shared Allocator allocator) @nogc nothrow pure @safe + in (allocator !is null) + { + this.allocator_ = allocator; + } + + /** + * This property checks if the allocator was set in the constructor + * and sets it to the default one, if not. + * + * Returns: Used allocator. + * + * Postcondition: $(D_INLINECODE allocator !is null) + */ + @property shared(Allocator) allocator() @nogc nothrow pure @safe + out (allocator; allocator !is null) + { + if (allocator_ is null) + { + allocator_ = defaultAllocator; + } + return allocator_; + } + + /// ditto + @property shared(Allocator) allocator() const @nogc nothrow pure @trusted + out (allocator; allocator !is null) + { + if (allocator_ is null) + { + return defaultAllocator; + } + return cast(shared Allocator) allocator_; + } +} + +shared Allocator allocator; + +private shared(Allocator) getAllocatorInstance() @nogc nothrow +{ + if (allocator is null) + { + version (TanyaNative) + { + import tanya.memory.mmappool : MmapPool; + defaultAllocator = MmapPool.instance; + } + else + { + import tanya.memory.mallocator : Mallocator; + defaultAllocator = Mallocator.instance; + } + } + return allocator; +} + +/** + * Returns: Default allocator. + * + * Postcondition: $(D_INLINECODE allocator !is null). + */ +@property shared(Allocator) defaultAllocator() @nogc nothrow pure @trusted +out (allocator; allocator !is null) +{ + return (cast(GetPureInstance!Allocator) &getAllocatorInstance)(); +} + +/** + * Sets the default allocator. + * + * Params: + * allocator = $(D_PSYMBOL Allocator) instance. + * + * Precondition: $(D_INLINECODE allocator !is null). + */ +@property void defaultAllocator(shared(Allocator) allocator) @nogc nothrow @safe +in (allocator !is null) +{ + .allocator = allocator; +} + +/** + * Params: + * size = Raw size. + * alignment = Alignment. + * + * Returns: Aligned size. + */ +size_t alignedSize(const size_t size, const size_t alignment = 8) +pure nothrow @safe @nogc +{ + return (size - 1) / alignment * alignment + alignment; +} + +/** + * Error thrown if memory allocation fails. + */ +final class OutOfMemoryError : Error +{ + /** + * Constructs new error. + * + * Params: + * msg = The message for the exception. + * file = The file where the exception occurred. + * line = The line number where the exception occurred. + * next = The previous exception in the chain of exceptions, if any. + */ + this(string msg = "Out of memory", + string file = __FILE__, + size_t line = __LINE__, + Throwable next = null) @nogc nothrow pure @safe + { + super(msg, file, line, next); + } + + /// ditto + this(string msg, + Throwable next, + string file = __FILE__, + size_t line = __LINE__) @nogc nothrow pure @safe + { + super(msg, file, line, next); + } +} + +/** + * Destroys and deallocates $(D_PARAM p) of type $(D_PARAM T). + * It is assumed the respective entities had been allocated with the same + * allocator. + * + * Params: + * T = Type of $(D_PARAM p). + * allocator = Allocator the $(D_PARAM p) was allocated with. + * p = Object or array to be destroyed. + */ +void dispose(T)(shared Allocator allocator, auto ref T p) +{ + () @trusted { allocator.deallocate(finalize(p)); }(); + p = null; +} + +/** + * Constructs a new class instance of type $(D_PARAM T) using $(D_PARAM args) + * as the parameter list for the constructor of $(D_PARAM T). + * + * Params: + * T = Class type. + * A = Types of the arguments to the constructor of $(D_PARAM T). + * allocator = Allocator. + * args = Constructor arguments of $(D_PARAM T). + * + * Returns: Newly created $(D_PSYMBOL T). + * + * Precondition: $(D_INLINECODE allocator !is null) + */ +T make(T, A...)(shared Allocator allocator, auto ref A args) +if (is(T == class)) +in (allocator !is null) +{ + auto mem = (() @trusted => allocator.allocate(stateSize!T))(); + if (mem is null) + { + onOutOfMemoryError(); + } + scope (failure) + { + () @trusted { allocator.deallocate(mem); }(); + } + + return emplace!T(mem[0 .. stateSize!T], args); +} + +/** + * Constructs a value object of type $(D_PARAM T) using $(D_PARAM args) + * as the parameter list for the constructor of $(D_PARAM T) and returns a + * pointer to the new object. + * + * Params: + * T = Object type. + * A = Types of the arguments to the constructor of $(D_PARAM T). + * allocator = Allocator. + * args = Constructor arguments of $(D_PARAM T). + * + * Returns: Pointer to the created object. + * + * Precondition: $(D_INLINECODE allocator !is null) + */ +T* make(T, A...)(shared Allocator allocator, auto ref A args) +if (!isPolymorphicType!T && !isAssociativeArray!T && !isArray!T) +in (allocator !is null) +{ + auto mem = (() @trusted => allocator.allocate(stateSize!T))(); + if (mem is null) + { + onOutOfMemoryError(); + } + scope (failure) + { + () @trusted { allocator.deallocate(mem); }(); + } + return emplace!T(mem[0 .. stateSize!T], args); +} + +/// +@nogc nothrow pure @safe unittest +{ + int* i = defaultAllocator.make!int(5); + assert(*i == 5); + defaultAllocator.dispose(i); +} + +/** + * Constructs a new array with $(D_PARAM n) elements. + * + * Params: + * T = Array type. + * E = Array element type. + * allocator = Allocator. + * n = Array size. + * + * Returns: Newly created array. + * + * Precondition: $(D_INLINECODE allocator !is null + * && n <= size_t.max / E.sizeof) + */ +T make(T : E[], E)(shared Allocator allocator, size_t n) +in (allocator !is null) +in (n <= size_t.max / E.sizeof) +{ + auto ret = allocator.resize!E(null, n); + + static if (hasElaborateDestructor!E) + { + for (auto range = ret; range.length != 0; range = range[1 .. $]) + { + emplace!E(cast(void[]) range[0 .. 1], E.init); + } + } + else + { + ret[] = E.init; + } + + return ret; +} + +/// +@nogc nothrow pure @safe unittest +{ + int[] i = defaultAllocator.make!(int[])(2); + assert(i.length == 2); + assert(i[0] == int.init && i[1] == int.init); + defaultAllocator.dispose(i); +} + +/* + * Destroys the object. + * Returns the memory should be freed. + */ +package void[] finalize(T)(ref T* p) +{ + if (p is null) + { + return null; + } + static if (hasElaborateDestructor!T) + { + destroy(*p); + } + return (cast(void*) p)[0 .. T.sizeof]; +} + +package void[] finalize(T)(ref T p) +if (isPolymorphicType!T) +{ + if (p is null) + { + return null; + } + static if (is(T == interface)) + { + version(Windows) + { + import core.sys.windows.unknwn : IUnknown; + static assert(!is(T : IUnknown), "COM interfaces can't be destroyed in " + ~ __PRETTY_FUNCTION__); + } + auto ob = cast(Object) p; + } + else + { + alias ob = p; + } + auto ptr = cast(void*) ob; + auto support = ptr[0 .. typeid(ob).initializer.length]; + + auto ppv = cast(void**) ptr; + if (!*ppv) + { + return null; + } + auto pc = cast(ClassInfo*) *ppv; + scope (exit) + { + *ppv = null; + } + + auto c = *pc; + do + { + // Assume the destructor is @nogc. Leave it nothrow since the destructor + // shouldn't throw and if it does, it is an error anyway. + if (c.destructor) + { + alias DtorType = void function(Object) pure nothrow @safe @nogc; + (cast(DtorType) c.destructor)(ob); + } + } + while ((c = c.base) !is null); + + if (ppv[1]) // if monitor is not null + { + _d_monitordelete(cast(Object) ptr, true); + } + return support; +} + +package void[] finalize(T)(ref T[] p) +{ + destroyAllImpl!(T[], T)(p); + return p; +} + +/** + * Allocates $(D_PSYMBOL OutOfMemoryError) in a static storage and throws it. + * + * Params: + * msg = Custom error message. + * + * Throws: $(D_PSYMBOL OutOfMemoryError). + */ +void onOutOfMemoryError(string msg = "Out of memory") +@nogc nothrow pure @trusted +{ + static ubyte[stateSize!OutOfMemoryError] memory; + alias PureType = OutOfMemoryError function(string) @nogc nothrow pure; + throw (cast(PureType) () => emplace!OutOfMemoryError(memory))(msg); +} + +// From druntime +extern (C) +private void _d_monitordelete(Object h, bool det) @nogc nothrow pure; + +/* + * Internal function used to create, resize or destroy a dynamic array. It + * may throw $(D_PSYMBOL OutOfMemoryError). The new + * allocated part of the array isn't initialized. This function can be trusted + * only in the data structures that can ensure that the array is + * allocated/rellocated/deallocated with the same allocator. + * + * Params: + * T = Element type of the array being created. + * allocator = The allocator used for getting memory. + * array = A reference to the array being changed. + * length = New array length. + * + * Returns: $(D_PARAM array). + */ +package(tanya) T[] resize(T)(shared Allocator allocator, + auto ref T[] array, + const size_t length) @trusted +{ + if (length == 0) + { + if (allocator.deallocate(array)) + { + return null; + } + else + { + onOutOfMemoryError(); + } + } + + void[] buf = array; + if (!allocator.reallocate(buf, length * T.sizeof)) + { + onOutOfMemoryError(); + } + // Casting from void[] is unsafe, but we know we cast to the original type. + array = cast(T[]) buf; + + return array; +} diff --git a/middle/tanya/memory/lifetime.d b/middle/tanya/memory/lifetime.d index 9bdc786..50a1b02 100644 --- a/middle/tanya/memory/lifetime.d +++ b/middle/tanya/memory/lifetime.d @@ -14,183 +14,10 @@ */ module tanya.memory.lifetime; -import tanya.memory : defaultAllocator; import tanya.memory.allocator; import tanya.meta.metafunction; import tanya.meta.trait; -/** - * Error thrown if memory allocation fails. - */ -final class OutOfMemoryError : Error -{ - /** - * Constructs new error. - * - * Params: - * msg = The message for the exception. - * file = The file where the exception occurred. - * line = The line number where the exception occurred. - * next = The previous exception in the chain of exceptions, if any. - */ - this(string msg = "Out of memory", - string file = __FILE__, - size_t line = __LINE__, - Throwable next = null) @nogc nothrow pure @safe - { - super(msg, file, line, next); - } - - /// ditto - this(string msg, - Throwable next, - string file = __FILE__, - size_t line = __LINE__) @nogc nothrow pure @safe - { - super(msg, file, line, next); - } -} - -/** - * Allocates $(D_PSYMBOL OutOfMemoryError) in a static storage and throws it. - * - * Params: - * msg = Custom error message. - * - * Throws: $(D_PSYMBOL OutOfMemoryError). - */ -void onOutOfMemoryError(string msg = "Out of memory") -@nogc nothrow pure @trusted -{ - static ubyte[stateSize!OutOfMemoryError] memory; - alias PureType = OutOfMemoryError function(string) @nogc nothrow pure; - throw (cast(PureType) () => emplace!OutOfMemoryError(memory))(msg); -} - -// From druntime -extern (C) -private void _d_monitordelete(Object h, bool det) @nogc nothrow pure; - -/* - * Internal function used to create, resize or destroy a dynamic array. It - * may throw $(D_PSYMBOL OutOfMemoryError). The new - * allocated part of the array isn't initialized. This function can be trusted - * only in the data structures that can ensure that the array is - * allocated/rellocated/deallocated with the same allocator. - * - * Params: - * T = Element type of the array being created. - * allocator = The allocator used for getting memory. - * array = A reference to the array being changed. - * length = New array length. - * - * Returns: $(D_PARAM array). - */ -package(tanya) T[] resize(T)(shared Allocator allocator, - auto ref T[] array, - const size_t length) @trusted -{ - if (length == 0) - { - if (allocator.deallocate(array)) - { - return null; - } - else - { - onOutOfMemoryError(); - } - } - - void[] buf = array; - if (!allocator.reallocate(buf, length * T.sizeof)) - { - onOutOfMemoryError(); - } - // Casting from void[] is unsafe, but we know we cast to the original type. - array = cast(T[]) buf; - - return array; -} - -/* - * Destroys the object. - * Returns the memory should be freed. - */ -package(tanya.memory) void[] finalize(T)(ref T* p) -{ - if (p is null) - { - return null; - } - static if (hasElaborateDestructor!T) - { - destroy(*p); - } - return (cast(void*) p)[0 .. T.sizeof]; -} - -package(tanya.memory) void[] finalize(T)(ref T p) -if (isPolymorphicType!T) -{ - if (p is null) - { - return null; - } - static if (is(T == interface)) - { - version(Windows) - { - import core.sys.windows.unknwn : IUnknown; - static assert(!is(T : IUnknown), "COM interfaces can't be destroyed in " - ~ __PRETTY_FUNCTION__); - } - auto ob = cast(Object) p; - } - else - { - alias ob = p; - } - auto ptr = cast(void*) ob; - auto support = ptr[0 .. typeid(ob).initializer.length]; - - auto ppv = cast(void**) ptr; - if (!*ppv) - { - return null; - } - auto pc = cast(ClassInfo*) *ppv; - scope (exit) - { - *ppv = null; - } - - auto c = *pc; - do - { - // Assume the destructor is @nogc. Leave it nothrow since the destructor - // shouldn't throw and if it does, it is an error anyway. - if (c.destructor) - { - alias DtorType = void function(Object) pure nothrow @safe @nogc; - (cast(DtorType) c.destructor)(ob); - } - } - while ((c = c.base) !is null); - - if (ppv[1]) // if monitor is not null - { - _d_monitordelete(cast(Object) ptr, true); - } - return support; -} - -package(tanya.memory) void[] finalize(T)(ref T[] p) -{ - destroyAllImpl!(T[], T)(p); - return p; -} - package(tanya) void destroyAllImpl(R, E)(R p) { static if (hasElaborateDestructor!E) @@ -202,136 +29,6 @@ package(tanya) void destroyAllImpl(R, E)(R p) } } -/** - * Destroys and deallocates $(D_PARAM p) of type $(D_PARAM T). - * It is assumed the respective entities had been allocated with the same - * allocator. - * - * Params: - * T = Type of $(D_PARAM p). - * allocator = Allocator the $(D_PARAM p) was allocated with. - * p = Object or array to be destroyed. - */ -void dispose(T)(shared Allocator allocator, auto ref T p) -{ - () @trusted { allocator.deallocate(finalize(p)); }(); - p = null; -} - -/** - * Constructs a new class instance of type $(D_PARAM T) using $(D_PARAM args) - * as the parameter list for the constructor of $(D_PARAM T). - * - * Params: - * T = Class type. - * A = Types of the arguments to the constructor of $(D_PARAM T). - * allocator = Allocator. - * args = Constructor arguments of $(D_PARAM T). - * - * Returns: Newly created $(D_PSYMBOL T). - * - * Precondition: $(D_INLINECODE allocator !is null) - */ -T make(T, A...)(shared Allocator allocator, auto ref A args) -if (is(T == class)) -in (allocator !is null) -{ - auto mem = (() @trusted => allocator.allocate(stateSize!T))(); - if (mem is null) - { - onOutOfMemoryError(); - } - scope (failure) - { - () @trusted { allocator.deallocate(mem); }(); - } - - return emplace!T(mem[0 .. stateSize!T], args); -} - -/** - * Constructs a value object of type $(D_PARAM T) using $(D_PARAM args) - * as the parameter list for the constructor of $(D_PARAM T) and returns a - * pointer to the new object. - * - * Params: - * T = Object type. - * A = Types of the arguments to the constructor of $(D_PARAM T). - * allocator = Allocator. - * args = Constructor arguments of $(D_PARAM T). - * - * Returns: Pointer to the created object. - * - * Precondition: $(D_INLINECODE allocator !is null) - */ -T* make(T, A...)(shared Allocator allocator, auto ref A args) -if (!isPolymorphicType!T && !isAssociativeArray!T && !isArray!T) -in (allocator !is null) -{ - auto mem = (() @trusted => allocator.allocate(stateSize!T))(); - if (mem is null) - { - onOutOfMemoryError(); - } - scope (failure) - { - () @trusted { allocator.deallocate(mem); }(); - } - return emplace!T(mem[0 .. stateSize!T], args); -} - -/// -@nogc nothrow pure @safe unittest -{ - int* i = defaultAllocator.make!int(5); - assert(*i == 5); - defaultAllocator.dispose(i); -} - -/** - * Constructs a new array with $(D_PARAM n) elements. - * - * Params: - * T = Array type. - * E = Array element type. - * allocator = Allocator. - * n = Array size. - * - * Returns: Newly created array. - * - * Precondition: $(D_INLINECODE allocator !is null - * && n <= size_t.max / E.sizeof) - */ -T make(T : E[], E)(shared Allocator allocator, size_t n) -in (allocator !is null) -in (n <= size_t.max / E.sizeof) -{ - auto ret = allocator.resize!E(null, n); - - static if (hasElaborateDestructor!E) - { - for (auto range = ret; range.length != 0; range = range[1 .. $]) - { - emplace!E(cast(void[]) range[0 .. 1], E.init); - } - } - else - { - ret[] = E.init; - } - - return ret; -} - -/// -@nogc nothrow pure @safe unittest -{ - int[] i = defaultAllocator.make!(int[])(2); - assert(i.length == 2); - assert(i[0] == int.init && i[1] == int.init); - defaultAllocator.dispose(i); -} - /** * Constructs a new object of type $(D_PARAM T) in $(D_PARAM memory) with the * given arguments. @@ -594,11 +291,7 @@ private void deinitialize(bool zero, T)(ref T value) * Precondition: `&source !is &target`. */ void moveEmplace(T)(ref T source, ref T target) @system -in -{ - assert(&source !is &target, "Source and target must be different"); -} -do +in (&source !is &target, "Source and target must be different") { static if (is(T == struct) || isStaticArray!T) { diff --git a/middle/tanya/memory/op.d b/middle/tanya/memory/op.d index 55a0676..e5702a3 100644 --- a/middle/tanya/memory/op.d +++ b/middle/tanya/memory/op.d @@ -52,13 +52,9 @@ private enum alignMask = size_t.sizeof - 1; * Precondition: $(D_INLINECODE source.length <= target.length). */ void copy(const void[] source, void[] target) @nogc nothrow pure @trusted -in -{ - assert(source.length <= target.length); - assert(source.length == 0 || source.ptr !is null); - assert(target.length == 0 || target.ptr !is null); -} -do +in (source.length <= target.length) +in (source.length == 0 || source.ptr !is null) +in (target.length == 0 || target.ptr !is null) { version (TanyaNative) { @@ -102,11 +98,7 @@ private template filledBytes(ubyte Byte, ubyte I = 0) * memory = Memory block. */ void fill(ubyte c = 0)(void[] memory) @trusted -in -{ - assert(memory.length == 0 || memory.ptr !is null); -} -do +in (memory.length == 0 || memory.ptr !is null) { version (TanyaNative) { @@ -152,13 +144,9 @@ do * Precondition: $(D_INLINECODE source.length <= target.length). */ void copyBackward(const void[] source, void[] target) @nogc nothrow pure @trusted -in -{ - assert(source.length <= target.length); - assert(source.length == 0 || source.ptr !is null); - assert(target.length == 0 || target.ptr !is null); -} -do +in (source.length <= target.length) +in (source.length == 0 || source.ptr !is null) +in (target.length == 0 || target.ptr !is null) { version (TanyaNative) { @@ -194,11 +182,7 @@ do */ inout(void[]) find(return inout void[] haystack, ubyte needle) @nogc nothrow pure @trusted -in -{ - assert(haystack.length == 0 || haystack.ptr !is null); -} -do +in (haystack.length == 0 || haystack.ptr !is null) { auto length = haystack.length; const size_t needleWord = size_t.max * needle; @@ -276,11 +260,7 @@ do */ inout(char[]) findNullTerminated(return inout char[] haystack) @nogc nothrow pure @trusted -in -{ - assert(haystack.length == 0 || haystack.ptr !is null); -} -do +in (haystack.length == 0 || haystack.ptr !is null) { auto length = haystack.length; enum size_t highBits = filledBytes!(0x01, 0); @@ -347,12 +327,8 @@ do * $(D_KEYWORD false) otherwise. */ bool equal(const void[] r1, const void[] r2) @nogc nothrow pure @trusted -in -{ - assert(r1.length == 0 || r1.ptr !is null); - assert(r2.length == 0 || r2.ptr !is null); -} -do +in (r1.length == 0 || r1.ptr !is null) +in (r2.length == 0 || r2.ptr !is null) { version (TanyaNative) { diff --git a/middle/tanya/memory/package.d b/middle/tanya/memory/package.d index c87eeb9..d2c051a 100644 --- a/middle/tanya/memory/package.d +++ b/middle/tanya/memory/package.d @@ -16,117 +16,5 @@ module tanya.memory; public import tanya.memory.allocator; public import tanya.memory.lifetime; -import tanya.meta.trait; deprecated("Use tanya.meta.trait.stateSize instead") public import tanya.meta.trait : stateSize; - -/** - * The mixin generates common methods for classes and structs using - * allocators. It provides a protected member, constructor and a read-only property, - * that checks if an allocator was already set and sets it to the default - * one, if not (useful for structs which don't have a default constructor). - */ -mixin template DefaultAllocator() -{ - /// Allocator. - protected shared Allocator allocator_; - - /** - * Params: - * allocator = The allocator should be used. - * - * Precondition: $(D_INLINECODE allocator_ !is null) - */ - this(shared Allocator allocator) @nogc nothrow pure @safe - in (allocator !is null) - { - this.allocator_ = allocator; - } - - /** - * This property checks if the allocator was set in the constructor - * and sets it to the default one, if not. - * - * Returns: Used allocator. - * - * Postcondition: $(D_INLINECODE allocator !is null) - */ - @property shared(Allocator) allocator() @nogc nothrow pure @safe - out (allocator; allocator !is null) - { - if (allocator_ is null) - { - allocator_ = defaultAllocator; - } - return allocator_; - } - - /// ditto - @property shared(Allocator) allocator() const @nogc nothrow pure @trusted - out (allocator; allocator !is null) - { - if (allocator_ is null) - { - return defaultAllocator; - } - return cast(shared Allocator) allocator_; - } -} - -shared Allocator allocator; - -private shared(Allocator) getAllocatorInstance() @nogc nothrow -{ - if (allocator is null) - { - version (TanyaNative) - { - import tanya.memory.mmappool; - defaultAllocator = MmapPool.instance; - } - else - { - import tanya.memory.mallocator; - defaultAllocator = Mallocator.instance; - } - } - return allocator; -} - -/** - * Returns: Default allocator. - * - * Postcondition: $(D_INLINECODE allocator !is null). - */ -@property shared(Allocator) defaultAllocator() @nogc nothrow pure @trusted -out (allocator; allocator !is null) -{ - return (cast(GetPureInstance!Allocator) &getAllocatorInstance)(); -} - -/** - * Sets the default allocator. - * - * Params: - * allocator = $(D_PSYMBOL Allocator) instance. - * - * Precondition: $(D_INLINECODE allocator !is null). - */ -@property void defaultAllocator(shared(Allocator) allocator) @nogc nothrow @safe -in (allocator !is null) -{ - .allocator = allocator; -} - -/** - * Params: - * size = Raw size. - * alignment = Alignment. - * - * Returns: Aligned size. - */ -size_t alignedSize(const size_t size, const size_t alignment = 8) -pure nothrow @safe @nogc -{ - return (size - 1) / alignment * alignment + alignment; -} diff --git a/middle/tanya/memory/smartref.d b/middle/tanya/memory/smartref.d index 953513e..ddde63b 100644 --- a/middle/tanya/memory/smartref.d +++ b/middle/tanya/memory/smartref.d @@ -23,7 +23,8 @@ */ module tanya.memory.smartref; -import tanya.memory; +import tanya.memory.allocator; +import tanya.memory.lifetime; import tanya.meta.trait; private template Payload(T) diff --git a/source/tanya/async/event/epoll.d b/source/tanya/async/event/epoll.d index 718e5e8..291950e 100644 --- a/source/tanya/async/event/epoll.d +++ b/source/tanya/async/event/epoll.d @@ -5,7 +5,7 @@ /** * Event loop implementation for Linux. * - * Copyright: Eugene Wissner 2016-2018. + * Copyright: Eugene Wissner 2016-2019. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) @@ -30,7 +30,7 @@ import tanya.async.protocol; import tanya.async.transport; import tanya.async.watcher; import tanya.container.array; -import tanya.memory; +import tanya.memory.allocator; import tanya.network.socket; extern (C) nothrow @nogc diff --git a/source/tanya/async/event/iocp.d b/source/tanya/async/event/iocp.d index acd37a5..a32e04c 100644 --- a/source/tanya/async/event/iocp.d +++ b/source/tanya/async/event/iocp.d @@ -5,7 +5,7 @@ /** * Event loop implementation for Windows. * - * Copyright: Eugene Wissner 2016-2018. + * Copyright: Eugene Wissner 2016-2019. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) @@ -26,7 +26,7 @@ import tanya.async.protocol; import tanya.async.transport; import tanya.async.watcher; import tanya.container.buffer; -import tanya.memory; +import tanya.memory.allocator; import tanya.network.socket; import tanya.sys.windows.winbase; diff --git a/source/tanya/async/event/kqueue.d b/source/tanya/async/event/kqueue.d index 683befa..563601a 100644 --- a/source/tanya/async/event/kqueue.d +++ b/source/tanya/async/event/kqueue.d @@ -5,7 +5,7 @@ /* * Event loop implementation for *BSD. * - * Copyright: Eugene Wissner 2016-2018. + * Copyright: Eugene Wissner 2016-2019. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) @@ -58,7 +58,7 @@ import tanya.async.loop; import tanya.async.transport; import tanya.async.watcher; import tanya.container.array; -import tanya.memory; +import tanya.memory.allocator; import tanya.network.socket; void EV_SET(kevent_t* kevp, typeof(kevent_t.tupleof) args) pure nothrow @nogc diff --git a/source/tanya/async/event/selector.d b/source/tanya/async/event/selector.d index 9e83261..1cc4515 100644 --- a/source/tanya/async/event/selector.d +++ b/source/tanya/async/event/selector.d @@ -5,7 +5,7 @@ /* * This module contains base implementations for reactor event loops. * - * Copyright: Eugene Wissner 2016-2018. + * Copyright: Eugene Wissner 2016-2019. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) @@ -25,7 +25,7 @@ import tanya.async.transport; import tanya.async.watcher; import tanya.container.array; import tanya.container.buffer; -import tanya.memory; +import tanya.memory.allocator; import tanya.network.socket; /** diff --git a/source/tanya/async/iocp.d b/source/tanya/async/iocp.d index 2887c4a..26c99fe 100644 --- a/source/tanya/async/iocp.d +++ b/source/tanya/async/iocp.d @@ -7,7 +7,7 @@ * * Note: Available only on Windows. * - * Copyright: Eugene Wissner 2016-2018. + * Copyright: Eugene Wissner 2016-2019. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) diff --git a/source/tanya/async/loop.d b/source/tanya/async/loop.d index 3fba090..2c13397 100644 --- a/source/tanya/async/loop.d +++ b/source/tanya/async/loop.d @@ -62,7 +62,7 @@ * } * --- * - * Copyright: Eugene Wissner 2016-2018. + * Copyright: Eugene Wissner 2016-2019. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) @@ -77,7 +77,7 @@ import tanya.async.watcher; import tanya.bitmanip; import tanya.container.buffer; import tanya.container.list; -import tanya.memory; +import tanya.memory.allocator; import tanya.network.socket; version (DisableBackends) diff --git a/source/tanya/async/package.d b/source/tanya/async/package.d index 140206e..ef30b2d 100644 --- a/source/tanya/async/package.d +++ b/source/tanya/async/package.d @@ -5,7 +5,7 @@ /** * This package provides asynchronous capabilities. * - * Copyright: Eugene Wissner 2016-2018. + * Copyright: Eugene Wissner 2016-2019. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) diff --git a/source/tanya/async/protocol.d b/source/tanya/async/protocol.d index 2795c16..035afaa 100644 --- a/source/tanya/async/protocol.d +++ b/source/tanya/async/protocol.d @@ -9,7 +9,7 @@ * When an event from the network arrives, a protocol method gets * called and can respond to the event. * - * Copyright: Eugene Wissner 2016-2018. + * Copyright: Eugene Wissner 2016-2019. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) diff --git a/source/tanya/async/transport.d b/source/tanya/async/transport.d index 108a295..c516ae2 100644 --- a/source/tanya/async/transport.d +++ b/source/tanya/async/transport.d @@ -6,7 +6,7 @@ * This module contains transports which are responsible for data dilvery * between two parties of an asynchronous communication. * - * Copyright: Eugene Wissner 2016-2018. + * Copyright: Eugene Wissner 2016-2019. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) diff --git a/source/tanya/async/watcher.d b/source/tanya/async/watcher.d index b257b5b..9feb1df 100644 --- a/source/tanya/async/watcher.d +++ b/source/tanya/async/watcher.d @@ -5,7 +5,7 @@ /** * Watchers register user's interest in some event. * - * Copyright: Eugene Wissner 2016-2018. + * Copyright: Eugene Wissner 2016-2019. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) @@ -19,7 +19,7 @@ import tanya.async.protocol; import tanya.async.transport; import tanya.container.buffer; import tanya.container.list; -import tanya.memory; +import tanya.memory.allocator; import tanya.network.socket; /** diff --git a/source/tanya/container/array.d b/source/tanya/container/array.d index 1bad819..0afd2ac 100644 --- a/source/tanya/container/array.d +++ b/source/tanya/container/array.d @@ -17,7 +17,8 @@ module tanya.container.array; import core.checkedint; import tanya.algorithm.comparison; import tanya.algorithm.mutation; -import tanya.memory; +import tanya.memory.allocator; +import tanya.memory.lifetime; import tanya.meta.trait; import tanya.meta.transform; import tanya.range; diff --git a/source/tanya/container/buffer.d b/source/tanya/container/buffer.d index 1bb0c4d..c5e8327 100644 --- a/source/tanya/container/buffer.d +++ b/source/tanya/container/buffer.d @@ -14,7 +14,7 @@ */ module tanya.container.buffer; -import tanya.memory; +import tanya.memory.allocator; import tanya.meta.trait; version (unittest) diff --git a/source/tanya/container/hashtable.d b/source/tanya/container/hashtable.d index 4df8af0..f458ca5 100644 --- a/source/tanya/container/hashtable.d +++ b/source/tanya/container/hashtable.d @@ -18,7 +18,8 @@ import tanya.algorithm.mutation; import tanya.container.array; import tanya.container.entry; import tanya.hash.lookup; -import tanya.memory; +import tanya.memory.allocator; +import tanya.memory.lifetime; import tanya.meta.trait; import tanya.meta.transform; import tanya.range.primitive; diff --git a/source/tanya/container/list.d b/source/tanya/container/list.d index bb1870c..279ebc4 100644 --- a/source/tanya/container/list.d +++ b/source/tanya/container/list.d @@ -17,7 +17,8 @@ module tanya.container.list; import tanya.algorithm.comparison; import tanya.container.entry; -import tanya.memory; +import tanya.memory.allocator; +import tanya.memory.lifetime; import tanya.meta.trait; import tanya.meta.transform; import tanya.range.array; diff --git a/source/tanya/container/set.d b/source/tanya/container/set.d index 3c9c362..7bfa6aa 100644 --- a/source/tanya/container/set.d +++ b/source/tanya/container/set.d @@ -18,7 +18,8 @@ module tanya.container.set; import tanya.container.array; import tanya.container.entry; import tanya.hash.lookup; -import tanya.memory; +import tanya.memory.allocator; +import tanya.memory.lifetime; import tanya.meta.trait; import tanya.meta.transform; import tanya.range.primitive; diff --git a/source/tanya/container/string.d b/source/tanya/container/string.d index 4263b1c..383ee7c 100644 --- a/source/tanya/container/string.d +++ b/source/tanya/container/string.d @@ -29,7 +29,8 @@ module tanya.container.string; import tanya.algorithm.comparison; import tanya.algorithm.mutation; import tanya.hash.lookup; -import tanya.memory; +import tanya.memory.allocator; +import tanya.memory.lifetime; import tanya.meta.trait; import tanya.meta.transform; import tanya.range.array; diff --git a/source/tanya/conv.d b/source/tanya/conv.d index 13e9235..2efeda2 100644 --- a/source/tanya/conv.d +++ b/source/tanya/conv.d @@ -15,7 +15,7 @@ module tanya.conv; import tanya.container.string; -import tanya.memory; +import tanya.memory.allocator; deprecated("Use tanya.memory.lifetime.emplace instead") public import tanya.memory.lifetime : emplace; import tanya.meta.trait; @@ -64,12 +64,8 @@ if (isInputRange!R && isSomeChar!(ElementType!R) && isIntegral!T && isUnsigned!T) -in -{ - assert(base >= 2); - assert(base <= 36); -} -do +in (base >= 2) +in (base <= 36) { T boundary = cast(T) (T.max / base); if (range.empty) diff --git a/source/tanya/exception.d b/source/tanya/exception.d index b65efd1..e8b94af 100644 --- a/source/tanya/exception.d +++ b/source/tanya/exception.d @@ -10,7 +10,7 @@ * Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/source/tanya/exception.d, * tanya/exception.d) */ -deprecated("Use tanya.memory.lifetimeinstead") +deprecated("Use tanya.memory.allocator instead") module tanya.exception; -public import tanya.memory.lifetime : onOutOfMemoryError, OutOfMemoryError; +public import tanya.memory.allocator : onOutOfMemoryError, OutOfMemoryError; diff --git a/source/tanya/format.d b/source/tanya/format.d index 5c63a5e..806fc1f 100644 --- a/source/tanya/format.d +++ b/source/tanya/format.d @@ -1175,11 +1175,7 @@ private struct uint128 } Tuple!(uint128, uint128) divMod(ulong rhs) const @nogc nothrow pure @safe - in - { - assert(rhs != uint128(), "Division by 0"); - } - do + in (rhs != uint128(), "Division by 0") { if (rhs == 1) { @@ -1279,11 +1275,7 @@ private int indexMismatch(ulong low, ulong high) @nogc nothrow pure @safe private char[] errol2(double value, return ref char[512] buffer, out int exponent) @nogc nothrow pure @safe -in -{ - assert(value > 9.007199254740992e15 && value < 3.40282366920938e38); -} -do +in (value > 9.007199254740992e15 && value < 3.40282366920938e38) { auto v = uint128(value); auto leftBoundary = v + raise2ToExp((value - previous(value)) / 2.0); @@ -1368,11 +1360,7 @@ do private char[] errolFixed(double value, return ref char[512] buffer, out int exponent) @nogc nothrow pure @safe -in -{ - assert(value >= 16.0 && value <= 9.007199254740992e15); -} -do +in (value >= 16.0 && value <= 9.007199254740992e15) { auto decimal = cast(ulong) value; auto n = cast(double) decimal; diff --git a/source/tanya/math/mp.d b/source/tanya/math/mp.d index 88a3fe6..f47177d 100644 --- a/source/tanya/math/mp.d +++ b/source/tanya/math/mp.d @@ -19,7 +19,8 @@ import tanya.algorithm.iteration; import tanya.algorithm.mutation; import tanya.container.array; import tanya.encoding.ascii; -import tanya.memory; +import tanya.memory.allocator; +import tanya.memory.lifetime; import tanya.meta.trait; import tanya.meta.transform; import tanya.range; diff --git a/source/tanya/math/random.d b/source/tanya/math/random.d index 7423c23..8974d7b 100644 --- a/source/tanya/math/random.d +++ b/source/tanya/math/random.d @@ -14,7 +14,7 @@ */ module tanya.math.random; -import tanya.memory; +import tanya.memory.allocator; import tanya.typecons; /// Maximum amount gathered from the entropy sources. diff --git a/source/tanya/net/uri.d b/source/tanya/net/uri.d index 00db019..6e72b45 100644 --- a/source/tanya/net/uri.d +++ b/source/tanya/net/uri.d @@ -16,7 +16,7 @@ module tanya.net.uri; import tanya.conv; import tanya.encoding.ascii; -import tanya.memory; +import tanya.memory.allocator; /** * Thrown if an invalid URI was specified. diff --git a/source/tanya/network/package.d b/source/tanya/network/package.d index 185d27c..6437845 100644 --- a/source/tanya/network/package.d +++ b/source/tanya/network/package.d @@ -5,7 +5,7 @@ /** * Network programming. * - * Copyright: Eugene Wissner 2016-2018. + * Copyright: Eugene Wissner 2016-2019. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) diff --git a/source/tanya/network/socket.d b/source/tanya/network/socket.d index 1b2d058..2bcab68 100644 --- a/source/tanya/network/socket.d +++ b/source/tanya/network/socket.d @@ -41,7 +41,7 @@ * For an example of an asynchronous server refer to the documentation of the * $(D_PSYMBOL tanya.async.loop) module. * - * Copyright: Eugene Wissner 2016-2018. + * Copyright: Eugene Wissner 2016-2019. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) @@ -55,7 +55,7 @@ import core.time; public import std.socket : SocketOption, SocketOptionLevel; import tanya.algorithm.comparison; import tanya.bitmanip; -import tanya.memory; +import tanya.memory.allocator; import tanya.meta.trait; import tanya.os.error; diff --git a/source/tanya/typecons.d b/source/tanya/typecons.d index 507cd3c..02f5e72 100644 --- a/source/tanya/typecons.d +++ b/source/tanya/typecons.d @@ -296,11 +296,7 @@ struct Option(T) /// ditto bool opEquals(U)(auto ref const U that) const if (ifTestable!(U, a => a == T.init) && !is(U == Option)) - in - { - assert(!isNothing); - } - do + in (!isNothing) { return get == that; } diff --git a/test/tanya/test/assertion.d b/test/tanya/test/assertion.d index 10105d7..daef334 100644 --- a/test/tanya/test/assertion.d +++ b/test/tanya/test/assertion.d @@ -13,7 +13,7 @@ * The functions can cause segmentation fault if the module is compiled * in production mode and the condition fails. * - * Copyright: Eugene Wissner 2017-2018. + * Copyright: Eugene Wissner 2017-2019. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) @@ -22,7 +22,7 @@ */ module tanya.test.assertion; -import tanya.memory; +import tanya.memory.allocator; import tanya.meta.trait; /** diff --git a/test/tanya/test/package.d b/test/tanya/test/package.d index ab6f861..f924833 100644 --- a/test/tanya/test/package.d +++ b/test/tanya/test/package.d @@ -5,7 +5,7 @@ /** * Test suite for $(D_KEYWORD unittest)-blocks. * - * Copyright: Eugene Wissner 2017-2018. + * Copyright: Eugene Wissner 2017-2019. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) diff --git a/test/tanya/test/stub.d b/test/tanya/test/stub.d index e1f8dcb..8756f95 100644 --- a/test/tanya/test/stub.d +++ b/test/tanya/test/stub.d @@ -5,7 +5,7 @@ /** * Range and generic type generators. * - * Copyright: Eugene Wissner 2018. + * Copyright: Eugene Wissner 2018-2019. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) diff --git a/tests/tanya/async/tests/loop.d b/tests/tanya/async/tests/loop.d index 60841b1..afee3bf 100644 --- a/tests/tanya/async/tests/loop.d +++ b/tests/tanya/async/tests/loop.d @@ -6,7 +6,7 @@ module tanya.async.tests.loop; import core.time; import tanya.async.loop; import tanya.async.watcher; -import tanya.memory; +import tanya.memory.allocator; private final class DummyWatcher : Watcher { diff --git a/tests/tanya/container/tests/array.d b/tests/tanya/container/tests/array.d index f551fb9..c8fb914 100644 --- a/tests/tanya/container/tests/array.d +++ b/tests/tanya/container/tests/array.d @@ -5,7 +5,7 @@ module tanya.container.tests.array; import tanya.algorithm.comparison; import tanya.container.array; -import tanya.memory; +import tanya.memory.allocator; import tanya.test.stub; // const arrays return usable ranges diff --git a/tests/tanya/container/tests/set.d b/tests/tanya/container/tests/set.d index 187869f..67259d9 100644 --- a/tests/tanya/container/tests/set.d +++ b/tests/tanya/container/tests/set.d @@ -4,7 +4,7 @@ module tanya.container.tests.set; import tanya.container.set; -import tanya.memory; +import tanya.memory.allocator; import tanya.test.stub; // Basic insertion logic. diff --git a/tests/tanya/math/tests/random.d b/tests/tanya/math/tests/random.d index 85ae3d0..2fe9f91 100644 --- a/tests/tanya/math/tests/random.d +++ b/tests/tanya/math/tests/random.d @@ -4,7 +4,7 @@ module tanya.math.tests.random; import tanya.math.random; -import tanya.memory; +import tanya.memory.allocator; static if (is(PlatformEntropySource)) @nogc @system unittest { diff --git a/tests/tanya/memory/tests/lifetime.d b/tests/tanya/memory/tests/lifetime.d index ff7020c..332b3d2 100644 --- a/tests/tanya/memory/tests/lifetime.d +++ b/tests/tanya/memory/tests/lifetime.d @@ -3,7 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ module tanya.memory.tests.lifetime; -import tanya.memory; +import tanya.memory.allocator; +import tanya.memory.lifetime; import tanya.test.stub; @nogc nothrow pure @safe unittest diff --git a/tests/tanya/memory/tests/smartref.d b/tests/tanya/memory/tests/smartref.d index ced8553..63308d8 100644 --- a/tests/tanya/memory/tests/smartref.d +++ b/tests/tanya/memory/tests/smartref.d @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ module tanya.memory.tests.smartref; -import tanya.memory; +import tanya.memory.allocator; import tanya.memory.smartref; import tanya.meta.trait; import tanya.test.stub; diff --git a/tests/tanya/tests/format.d b/tests/tanya/tests/format.d index b4a019d..f080a67 100644 --- a/tests/tanya/tests/format.d +++ b/tests/tanya/tests/format.d @@ -175,7 +175,7 @@ import tanya.range; // Aggregate types @system unittest // Object.toString has no attributes. { - import tanya.memory; + import tanya.memory.allocator; import tanya.memory.smartref; interface I