Merge pull request #18 from vibe-d/fix_for_dmd2075
Use a thread local allocator instead of processAllocator in HashMap.
This commit is contained in:
commit
490037a5bd
|
@ -7,3 +7,12 @@ public import std.experimental.allocator.building_blocks.region;
|
||||||
public import std.experimental.allocator.building_blocks.stats_collector;
|
public import std.experimental.allocator.building_blocks.stats_collector;
|
||||||
public import std.experimental.allocator.gc_allocator;
|
public import std.experimental.allocator.gc_allocator;
|
||||||
public import std.experimental.allocator.mallocator;
|
public import std.experimental.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;
|
||||||
|
}
|
||||||
|
|
|
@ -219,7 +219,7 @@ struct HashMap(TKey, TValue, Traits = DefaultHashMapTraits!TKey)
|
||||||
scope(exit) m_resizing = false;
|
scope(exit) m_resizing = false;
|
||||||
|
|
||||||
if (!m_allocator) {
|
if (!m_allocator) {
|
||||||
try m_allocator = processAllocator();
|
try m_allocator = vibeThreadAllocator();
|
||||||
catch (Exception e) assert(false, e.msg);
|
catch (Exception e) assert(false, e.msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue