call the garbage collector the right way

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@902 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc
2003-10-17 02:11:21 +00:00
parent 76160f72a8
commit 526ec2e50f
12 changed files with 172 additions and 70 deletions

21
C/bb.c
View File

@@ -271,7 +271,12 @@ p_bb_get(void)
if (p == NULL || p->Element == NULL)
return(FALSE);
READ_LOCK(p->BBRWLock);
out = Yap_FetchTermFromDB(p->Element,3);
while ((out = Yap_FetchTermFromDB(p->Element)) == 0L) {
if (!Yap_gc(2, YENV, P)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
return(TermNil);
}
}
READ_UNLOCK(p->BBRWLock);
return(Yap_unify(ARG2,out));
}
@@ -286,7 +291,12 @@ p_bb_delete(void)
p = FetchBBProp(t1, "bb_delete/2", CurrentModule);
if (p == NULL || p->Element == NULL)
return(FALSE);
out = Yap_FetchTermFromDB(p->Element,3);
while ((out = Yap_FetchTermFromDB(p->Element)) == 0L) {
if (!Yap_gc(2, YENV, P)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
return(TermNil);
}
}
WRITE_LOCK(p->BBRWLock);
Yap_ReleaseTermFromDB(p->Element);
p->Element = NULL;
@@ -305,7 +315,12 @@ p_bb_update(void)
if (p == NULL || p->Element == NULL)
return(FALSE);
WRITE_LOCK(p->BBRWLock);
out = Yap_FetchTermFromDB(p->Element,3);
while ((out = Yap_FetchTermFromDB(p->Element)) == 0L) {
if (!Yap_gc(3, YENV, P)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
return(TermNil);
}
}
if (!Yap_unify(ARG2,out)) {
WRITE_UNLOCK(p->BBRWLock);
return(FALSE);