Branch: Tag:

2016-02-29

2016-02-29 14:45:11 by Henrik Grubbström (Grubba) <grubba@grubba.org>

GC [mappings]: Added do_gc_weak_mapping().

It is now possible to request a quick gc of a mapping with weak references.

5037:    delaysleep(delay, do_abort_on_signal, !do_abort_on_signal && delay<10);   }    - /*! @decl int gc() + /*! @decl int gc(mapping|void quick)    *!    *! Force garbage collection.    *! -  *! This function checks all the memory for cyclic structures such +  *! @param quick +  *! Perform a quick garbage collection on just this value, +  *! which must have been made weak by @[set_weak_flag()]. +  *! All values that only have a single reference from +  *! @[quick] will then be freed. +  *! +  *! When @[quick] hasn't been specified or is @[UNDEFINED], +  *! this function checks all the memory for cyclic structures such    *! as arrays containing themselves and frees them if appropriate.    *! It also frees up destructed objects and things with only weak    *! references.
5064:    */   void f_gc(INT32 args)   { +  ptrdiff_t res = 0; +  if (args && (TYPEOF(Pike_sp[-args]) == PIKE_T_MAPPING)) { +  res = do_gc_weak_mapping(Pike_sp[-args].u.mapping);    pop_n_elems(args); -  push_int(do_gc(NULL, 1)); +  } else { +  pop_n_elems(args); +  res = do_gc(NULL, 1);    } -  +  push_int(res); + }      #ifdef TYPEP   #undef TYPEP
10191:         /* function(:int) */ -  ADD_EFUN("gc",f_gc,tFunc(tNone,tInt),OPT_SIDE_EFFECT); +  ADD_EFUN("gc", f_gc, tFunc(tMix, tInt), OPT_SIDE_EFFECT);      /* function(:string) */    ADD_EFUN("version", f_version,tFunc(tNone,tStr), OPT_TRY_OPTIMIZE);