Skip to content

Commit

Permalink
libgap API: expose minimal interface to garbage collector (#4215)
Browse files Browse the repository at this point in the history
Add libgap interfaces to the garbage collector.  As discussed in #3030
these are probably the minimal interfaces that need to be exposed, and
are compatible with all current GC implementations.

As suggested at #3030 (comment)
GAP_CollectBags only takes a <full> argument, but not <size>
  • Loading branch information
embray committed Jan 27, 2021
1 parent 2bb044b commit 653dfd1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/libgap-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ void GAP_Initialize(int argc,
}


////
//// Garbage collector interface
////
void GAP_MarkBag(Obj obj)
{
MarkBag(obj);
}

void GAP_CollectBags(BOOL full)
{
CollectBags(0, full);
}


////
//// program evaluation and execution
////
Expand Down
20 changes: 20 additions & 0 deletions src/libgap-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,26 @@ void GAP_Initialize(int argc,
int handleSignals);


////
//// Garbage collector
////

// Manual management of the GAP garbage collector: for cases where you want
// a GAP object to be long-lived beyond the context of the stack frame where
// it was created, it is necessary to call GAP_MarkBag on the object when
// the garbage collector is run by the markBagsCallback function passed to
// GAP_Initialize.
void GAP_MarkBag(Obj obj);

// Manually run the garbage collector.
// A <full> collection checks all previously allocated objects, including those
// that have survived at least one previous garbage collection.
// A partial collection will attempt to clean up only recently allocated
// objects which have not been garbage-collected yet, and is hence normally
// a faster operation.
void GAP_CollectBags(BOOL full);


////
//// program evaluation and execution
////
Expand Down

0 comments on commit 653dfd1

Please sign in to comment.