Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1096 from CyberShadow/pull-20150112-110941
Browse files Browse the repository at this point in the history
gc.gc: Simplify implementation of rootIter and rangeIter
  • Loading branch information
MartinNowak committed Jan 13, 2015
2 parents 097bb6f + c1b7088 commit 0815912
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions src/gc/gc.d
Expand Up @@ -1096,23 +1096,20 @@ class GC
}


private auto rootIterImpl(scope int delegate(ref Root) nothrow dg) nothrow
{
gcLock.lock();
auto res = gcx.roots.opApply(dg);
gcLock.unlock();
return res;
}

/**
*
*/
@property auto rootIter() @nogc
{
static struct Iter
{
private GC gc;
auto opApply(scope int delegate(ref Root) nothrow dg)
{
gc.gcLock.lock();
auto res = gc.gcx.roots.opApply(dg);
gc.gcLock.unlock();
return res;
}
}
return Iter(this);
return &rootIterImpl;
}


Expand Down Expand Up @@ -1161,23 +1158,20 @@ class GC
gcLock.unlock();
}

private auto rangeIterImpl(scope int delegate(ref Range) nothrow dg) nothrow
{
gcLock.lock();
auto res = gcx.ranges.opApply(dg);
gcLock.unlock();
return res;
}

/**
*
*/
@property auto rangeIter() @nogc
{
static struct Iter
{
private GC gc;
auto opApply(scope int delegate(ref Range) nothrow dg)
{
gc.gcLock.lock();
auto res = gc.gcx.ranges.opApply(dg);
gc.gcLock.unlock();
return res;
}
}
return Iter(this);
return &rangeIterImpl;
}


Expand Down

0 comments on commit 0815912

Please sign in to comment.