pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:1:   #include "global.h" - RCSID("$Id: threads.c,v 1.158 2001/06/20 23:16:32 mast Exp $"); + RCSID("$Id: threads.c,v 1.159 2001/06/30 21:28:36 mast Exp $");      PMOD_EXPORT int num_threads = 1;   PMOD_EXPORT int threads_disabled = 0;      #ifdef _REENTRANT   #include "threads.h"   #include "array.h"   #include "mapping.h"   #include "object.h"   #include "pike_macros.h"
pike.git/src/threads.c:1318:   {    struct thread_state *tmp=THIS_THREAD;    if(tmp->thread_local != NULL)    gc_recurse_mapping(tmp->thread_local);   }      static void thread_was_checked(struct object *o)   {    struct thread_state *tmp=THIS_THREAD;    if(tmp->thread_local != NULL) -  debug_gc_check(tmp->thread_local, T_OBJECT, o); +  debug_gc_check2(tmp->thread_local, T_OBJECT, o, +  " as mapping for thread local values in thread");      #ifdef PIKE_DEBUG    if(tmp->swapped)    {    struct pike_frame *f;    debug_malloc_touch(o);    debug_gc_xmark_svalues(tmp->state.evaluator_stack,    tmp->state.stack_pointer-tmp->state.evaluator_stack-1,    " in idle thread stack");   
pike.git/src/threads.c:1440:    if(Pike_interpreter.thread_id == NULL)    Pike_error("Trying to set Thread.Local without thread!\n");       if((m = OBJ2THREAD(Pike_interpreter.thread_id)->thread_local) == NULL)    m = OBJ2THREAD(Pike_interpreter.thread_id)->thread_local =    allocate_mapping(4);       mapping_insert(m, &key, &Pike_sp[-1]);   }    + #ifdef PIKE_DEBUG + void gc_check_thread_local (struct object *o) + { +  /* Only used by with locate_references. */ +  if (Pike_in_gc == GC_PASS_LOCATE) { +  struct svalue key, *val; +  INT32 x; +  struct thread_state *s; +  +  key.u.integer = ((struct thread_local *)CURRENT_STORAGE)->id; +  key.type = T_INT; +  key.subtype = NUMBER_NUMBER; +  +  /* Hmm, should this be used here? We know we always got the +  * interpreter lock. */ +  /* mt_lock( & thread_table_lock ); */ +  for(x=0; x<THREAD_TABLE_SIZE; x++) +  for(s=thread_table_chains[x]; s; s=s->hashlink) { +  if (s->thread_local && +  (val = low_mapping_lookup(s->thread_local, &key))) +  debug_gc_check_svalues2(val, 1, T_OBJECT, o, +  " as thread local value in Thread.Local object" +  " (indirect ref)"); +  } +  /* mt_unlock( & thread_table_lock ); */ +  } + } + #endif +    /*! @endclass    */      /*! @endmodule    */      /* Thread farm code by Per    *    */   static struct farmer {
pike.git/src/threads.c:1681:    add_global_program("_disable_threads", tmp);    free_program(tmp);    }       START_NEW_PROGRAM_ID(THREAD_LOCAL);    ADD_STORAGE(struct thread_local);    ADD_FUNCTION("get",f_thread_local_get,tFunc(tNone,tMix),0);    ADD_FUNCTION("set",f_thread_local_set,tFunc(tSetvar(1,tMix),tVar(1)),0);    ADD_FUNCTION("create", f_thread_local_create,    tFunc(tVoid,tVoid), ID_STATIC); + #ifdef PIKE_DEBUG +  set_gc_check_callback(gc_check_thread_local); + #endif    thread_local_prog=Pike_compiler->new_program;    add_ref(thread_local_prog);    end_class("thread_local", 0);    if(!thread_local_prog)    fatal("Failed to initialize thread_local program!\n");    ADD_EFUN("thread_local", f_thread_local,    tFunc(tNone,tObjIs_THREAD_LOCAL),    OPT_EXTERNAL_DEPEND);       START_NEW_PROGRAM_ID(THREAD_ID);