pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:390: Inside #if defined(INTERNAL_PROFILING)
  #ifdef INTERNAL_PROFILING   PMOD_EXPORT unsigned long thread_yields = 0;   #endif   static int th_running = 0;   static PIKE_MUTEX_T interpreter_lock;   static PIKE_MUTEX_T interpreter_lock_wanted;   PIKE_MUTEX_T thread_table_lock;   static PIKE_MUTEX_T interleave_lock;   static struct program *mutex_program = NULL;   static struct program *mutex_key = 0; + static struct program *condition_program = NULL;   PMOD_EXPORT struct program *thread_id_prog = 0;   static struct program *thread_local_prog = 0;   PMOD_EXPORT ptrdiff_t thread_storage_offset;   static int live_threads = 0;   static COND_T live_threads_change;   static COND_T threads_disabled_change;      struct thread_local_var   {    INT32 id;
pike.git/src/threads.c:2406:    push_static_text("Thread.Mutex(/*locked by 0x");    push_int64(PTR_TO_INT(THREAD_T_TO_PTR(OB2KEY(m->key)->owner->id)));    f_int2hex(1);    push_static_text("*/)");    f_add(3);    } else {    push_static_text("Thread.Mutex()");    }   }    + /*! @decl Condition cond() +  *! +  *! Create a @[Condition]. +  *! +  *! This function is equivalent to +  *! @code +  *! Thread.Condition(mux); +  *! @endcode +  *! +  *! @seealso +  *! @[Condition] +  */ + void f_mutex_cond(INT32 args) + { +  ref_push_object_inherit(Pike_fp->current_object, +  Pike_fp->context - +  Pike_fp->current_program->inherits); +  push_object(clone_object(condition_program, 1)); + } +    void init_mutex_obj(struct object *UNUSED(o))   {    co_init(& THIS_MUTEX->condition);   #ifdef PIKE_NULL_IS_SPECIAL    THIS_MUTEX->key=0;    THIS_MUTEX->num_waiting = 0;   #endif   }      void exit_mutex_obj(struct object *UNUSED(o))
pike.git/src/threads.c:3420:    ADD_STORAGE(struct mutex_storage);    ADD_FUNCTION("lock",f_mutex_lock,    tFunc(tOr(tInt02,tVoid),tObjIs_THREAD_MUTEX_KEY),0);    ADD_FUNCTION("trylock",f_mutex_trylock,    tFunc(tOr(tInt02,tVoid),tObjIs_THREAD_MUTEX_KEY),0);    ADD_FUNCTION("current_locking_thread",f_mutex_locking_thread,    tFunc(tNone,tObjIs_THREAD_ID), 0);    ADD_FUNCTION("current_locking_key",f_mutex_locking_key,    tFunc(tNone,tObjIs_THREAD_MUTEX_KEY), 0);    ADD_FUNCTION("_sprintf",f_mutex__sprintf,tFunc(tInt,tStr),0); +  ADD_FUNCTION("cond", f_mutex_cond, tFunc(tNone, tObjIs_THREAD_CONDITION), 0);    set_init_callback(init_mutex_obj);    set_exit_callback(exit_mutex_obj);    mutex_program = Pike_compiler->new_program;    add_ref(mutex_program);    end_class("mutex", 0);       START_NEW_PROGRAM_ID(THREAD_CONDITION);    ADD_STORAGE(struct pike_cond);    PIKE_MAP_VARIABLE("_mutex", OFFSETOF(pike_cond, mutex_obj),    tObjIs_THREAD_MUTEX, T_OBJECT, ID_PROTECTED|ID_PRIVATE);
pike.git/src/threads.c:3441:    tFunc(tOr(tObjIs_THREAD_MUTEX, tVoid), tVoid),    ID_PROTECTED);    ADD_FUNCTION("wait",f_cond_wait,    tOr(tFunc(tObjIs_THREAD_MUTEX_KEY tOr3(tVoid, tIntPos, tFloat),    tVoid),    tFunc(tObjIs_THREAD_MUTEX_KEY tIntPos tIntPos, tVoid)),0);    ADD_FUNCTION("signal",f_cond_signal,tFunc(tNone,tVoid),0);    ADD_FUNCTION("broadcast",f_cond_broadcast,tFunc(tNone,tVoid),0);    set_init_callback(init_cond_obj);    set_exit_callback(exit_cond_obj); +  condition_program = Pike_compiler->new_program; +  add_ref(condition_program);    end_class("condition", 0);       {    struct program *tmp;    START_NEW_PROGRAM_ID(THREAD_DISABLE_THREADS);    set_init_callback(init_threads_disable);    set_exit_callback(exit_threads_disable);    tmp = Pike_compiler->new_program;    add_ref(tmp);    end_class("threads_disabled", 0);
pike.git/src/threads.c:3586:       destruct(backend_thread_obj);    free_object(backend_thread_obj);    backend_thread_obj = NULL;       Pike_interpreter_pointer = original_interpreter;       destruct_objects_to_destruct_cb();    }    +  if(condition_program) +  { +  free_program(condition_program); +  condition_program = NULL; +  } +     if(mutex_program)    {    free_program(mutex_program);    mutex_program = NULL;    }       if(mutex_key)    {    free_program(mutex_key);    mutex_key=0;