vibe.internal.allocator 4/10(40%) line coverage

      
10
20
30
40
50
60
70
80
90
100
110
120
130
1426
1526
162
1726
180
190
200
210
220
230
240
250
260
270
280
290
300
310
320
330
340
350
360
370
380
390
400
410
module vibe.internal.allocator; public import stdx.allocator; public import stdx.allocator.building_blocks.allocator_list; public import stdx.allocator.building_blocks.null_allocator; public import stdx.allocator.building_blocks.region; public import stdx.allocator.building_blocks.stats_collector; public import stdx.allocator.gc_allocator; public import stdx.allocator.mallocator; // NOTE: this needs to be used instead of theAllocator due to Phobos issue 17564 @property IAllocator vibeThreadAllocator() @safe nothrow @nogc { static IAllocator s_threadAllocator; if (!s_threadAllocator) s_threadAllocator = () @trusted { return allocatorObject(GCAllocator.instance); } (); return s_threadAllocator; } auto makeGCSafe(T, Allocator, A...)(Allocator allocator, A args) { import core.memory : GC; import std.traits : hasIndirections; auto ret = allocator.make!T(args); static if (is (T == class)) enum tsize = __traits(classInstanceSize, T); else enum tsize = T.sizeof; static if (hasIndirections!T) () @trusted { GC.addRange(cast(void*)ret, tsize, typeid(T)); } (); return ret; } void disposeGCSafe(T, Allocator)(Allocator allocator, T obj) { import core.memory : GC; import std.traits : hasIndirections; static if (hasIndirections!T) GC.removeRange(cast(void*)obj); allocator.dispose(obj); }