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

Commit d5088da

Browse files
committed
Rename ConservativeGC._in_Finalizer to _is_Locked
Since this field was used to prevent recursive calls to GC to itself while is locked, not just when running inside finalizer, this field is renamed to better describe its purpose.
1 parent 4c97b07 commit d5088da

File tree

1 file changed

+10
-10
lines changed
  • src/gc/impl/conservative

1 file changed

+10
-10
lines changed

src/gc/impl/conservative/gc.d

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,12 @@ class ConservativeGC : GC
259259

260260
import core.internal.spinlock;
261261
static gcLock = shared(AlignedSpinLock)(SpinLock.Contention.lengthy);
262-
static bool _inFinalizer;
262+
static bool _isLocked;
263263

264264
// lock GC, throw InvalidMemoryOperationError on recursive locking during finalization
265265
static void lockNR() @nogc nothrow
266266
{
267-
if (_inFinalizer)
267+
if (_isLocked)
268268
onInvalidMemoryOperationError();
269269
gcLock.lock();
270270
}
@@ -817,7 +817,7 @@ class ConservativeGC : GC
817817

818818
void free(void *p) nothrow
819819
{
820-
if (!p || _inFinalizer)
820+
if (!p || _isLocked)
821821
{
822822
return;
823823
}
@@ -1120,7 +1120,7 @@ class ConservativeGC : GC
11201120

11211121
bool inFinalizer() nothrow
11221122
{
1123-
return _inFinalizer;
1123+
return _isLocked;
11241124
}
11251125

11261126

@@ -1500,8 +1500,8 @@ struct Gcx
15001500
*/
15011501
void runFinalizers(in void[] segment) nothrow
15021502
{
1503-
ConservativeGC._inFinalizer = true;
1504-
scope (failure) ConservativeGC._inFinalizer = false;
1503+
ConservativeGC._isLocked = true;
1504+
scope (failure) ConservativeGC._isLocked = false;
15051505

15061506
foreach (pool; pooltable[0 .. npools])
15071507
{
@@ -1518,7 +1518,7 @@ struct Gcx
15181518
spool.runFinalizers(segment);
15191519
}
15201520
}
1521-
ConservativeGC._inFinalizer = false;
1521+
ConservativeGC._isLocked = false;
15221522
}
15231523

15241524
Pool* findPool(void* p) pure nothrow
@@ -2408,12 +2408,12 @@ struct Gcx
24082408
start = stop;
24092409
}
24102410

2411-
ConservativeGC._inFinalizer = true;
2411+
ConservativeGC._isLocked = true;
24122412
size_t freedLargePages=void;
24132413
{
2414-
scope (failure) ConservativeGC._inFinalizer = false;
2414+
scope (failure) ConservativeGC._isLocked = false;
24152415
freedLargePages = sweep();
2416-
ConservativeGC._inFinalizer = false;
2416+
ConservativeGC._isLocked = false;
24172417
}
24182418

24192419
if (config.profile)

0 commit comments

Comments
 (0)