pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:2451:    struct mutex_storage *m = THIS_MUTEX;       pop_n_elems(args);       if (m->key)    ref_push_object(m->key);    else    push_int(0);   }    + /*! @decl protected string _sprintf(int c) +  *! +  *! Describes the mutex including the thread that currently holds the lock +  *! (if any). +  */ + void f_mutex__sprintf (INT32 args) + { +  struct mutex_storage *m = THIS_MUTEX; +  int c = 0; +  if(args>0 && TYPEOF(Pike_sp[-args]) == PIKE_T_INT) +  c = Pike_sp[-args].u.integer; +  pop_n_elems (args); +  if(c != 'O') { +  push_undefined(); +  return; +  } +  if (m->key && OB2KEY(m->key)->owner) { +  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_text("Thread.Mutex()"); +  } + } +    void init_mutex_obj(struct object *UNUSED(o))   {    co_init(& THIS_MUTEX->condition);    THIS_MUTEX->key=0;    THIS_MUTEX->num_waiting = 0;   }      void exit_mutex_obj(struct object *UNUSED(o))   {    struct mutex_storage *m = THIS_MUTEX;
pike.git/src/threads.c:2868:   void f_thread_id__sprintf (INT32 args)   {    int c = 0;    if(args>0 && TYPEOF(Pike_sp[-args]) == PIKE_T_INT)    c = Pike_sp[-args].u.integer;    pop_n_elems (args);    if(c != 'O') {    push_undefined();    return;    } -  push_text ("Thread.Thread("); +  push_static_text ("Thread.Thread(0x");    push_int64(PTR_TO_INT(THREAD_T_TO_PTR(THIS_THREAD->id))); -  push_text (")"); +  f_int2hex(1); +  push_static_text (")");    f_add (3);   }      /*! @decl protected int id_number()    *!    *! Returns an id number identifying the thread.    *!    *! @note    *! This function was added in Pike 7.2.204.    */
pike.git/src/threads.c:3444:    START_NEW_PROGRAM_ID(THREAD_MUTEX);    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(tNone,tStr),0);    set_init_callback(init_mutex_obj);    set_exit_callback(exit_mutex_obj);    end_class("mutex", 0);       START_NEW_PROGRAM_ID(THREAD_MUTEX_COMPAT_7_4);    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);