/* -----------------------------------------------------------------------------
- * $Id: Weak.c,v 1.25 2002/06/19 12:01:28 simonmar Exp $
+ * $Id: Weak.c,v 1.32 2004/08/13 13:11:13 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
#include "RtsFlags.h"
#include "Weak.h"
#include "Storage.h"
+#include "Schedule.h"
#include "Prelude.h"
#include "RtsAPI.h"
{
StgWeak *w;
+ rts_lock();
while ((w = weak_ptr_list)) {
weak_ptr_list = w->link;
if (w->header.info != &stg_DEAD_WEAK_info) {
- w->header.info = &stg_DEAD_WEAK_info;
+ SET_HDR(w, &stg_DEAD_WEAK_info, w->header.prof.ccs);
IF_DEBUG(weak,fprintf(stderr,"Finalising weak pointer at %p -> %p\n", w, w->key));
if (w->finalizer != &stg_NO_FINALIZER_closure) {
- rts_mainEvalIO(w->finalizer,NULL);
+ rts_evalLazyIO(w->finalizer,NULL);
+ rts_unlock();
+ rts_lock();
}
}
}
+ rts_unlock();
}
/*
IF_DEBUG(weak,fprintf(stderr,"weak: batching %d finalizers\n", n));
arr = (StgMutArrPtrs *)allocate(sizeofW(StgMutArrPtrs) + n);
+ TICK_ALLOC_PRIM(sizeofW(StgMutArrPtrs), n, 0);
SET_HDR(arr, &stg_MUT_ARR_PTRS_FROZEN_info, CCS_SYSTEM);
+ arr->mut_link = NULL;
arr->ptrs = n;
n = 0;