pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: threads.c,v 1.205 2003/02/16 03:50:23 mast Exp $ + || $Id: threads.c,v 1.206 2003/02/16 13:55:20 mast Exp $   */      #ifndef CONFIGURE_TEST   #include "global.h" - RCSID("$Id: threads.c,v 1.205 2003/02/16 03:50:23 mast Exp $"); + RCSID("$Id: threads.c,v 1.206 2003/02/16 13:55:20 mast Exp $");      PMOD_EXPORT int num_threads = 1;   PMOD_EXPORT int threads_disabled = 0;   #endif /* !CONFIGURE_TEST */      #ifdef _REENTRANT      #ifndef CONFIGURE_TEST      #include "threads.h"
pike.git/src/threads.c:1799:    th_running = 1;   #endif   }      void th_init(void)   {    ptrdiff_t mutex_key_offset;      #ifdef UNIX_THREADS    - /* function(int:void) */ +     ADD_EFUN("thread_set_concurrency",f_thread_set_concurrency,tFunc(tInt,tVoid), OPT_SIDE_EFFECT);   #endif       START_NEW_PROGRAM_ID(THREAD_MUTEX_KEY);    mutex_key_offset = ADD_STORAGE(struct key_storage);    /* This is needed to allow the gc to find the possible circular reference.    * It also allows a thread to take over ownership of a key.    */    PIKE_MAP_VARIABLE("_owner", mutex_key_offset + OFFSETOF(key_storage, owner),    tObjIs_THREAD_ID, T_OBJECT, 0);
pike.git/src/threads.c:1825:    add_ref(mutex_key);    end_class("mutex_key", 0);    mutex_key->flags|=PROGRAM_DESTRUCT_IMMEDIATE;   #ifdef PIKE_DEBUG    if(!mutex_key)    Pike_fatal("Failed to initialize mutex_key program!\n");   #endif       START_NEW_PROGRAM_ID(THREAD_MUTEX);    ADD_STORAGE(struct mutex_storage); -  /* function(int(0..2)|void:object(mutex_key)) */ +     ADD_FUNCTION("lock",f_mutex_lock,    tFunc(tOr(tInt02,tVoid),tObjIs_THREAD_MUTEX_KEY),0); -  /* function(int(0..2)|void:object(mutex_key)) */ +     ADD_FUNCTION("trylock",f_mutex_trylock,    tFunc(tOr(tInt02,tVoid),tObjIs_THREAD_MUTEX_KEY),0); -  /* function(:object(Pike_interpreter.thread_id)) */ +     ADD_FUNCTION("current_locking_thread",f_mutex_locking_thread,    tFunc(tNone,tObjIs_THREAD_ID), 0); -  /* function(:object(Pike_interpreter.thread_id)) */ +     ADD_FUNCTION("current_locking_key",f_mutex_locking_key,    tFunc(tNone,tObjIs_THREAD_MUTEX_KEY), 0);    set_init_callback(init_mutex_obj);    set_exit_callback(exit_mutex_obj);    end_class("mutex", 0);       START_NEW_PROGRAM_ID(THREAD_CONDITION);    ADD_STORAGE(COND_T); -  /* function(object(mutex_key):void) */ +     ADD_FUNCTION("wait",f_cond_wait,    tFunc(tObjIs_THREAD_MUTEX_KEY,tVoid),0); -  /* function(:void) */ +     ADD_FUNCTION("signal",f_cond_signal,tFunc(tNone,tVoid),0); -  /* function(:void) */ +     ADD_FUNCTION("broadcast",f_cond_broadcast,tFunc(tNone,tVoid),0);    set_init_callback(init_cond_obj);    set_exit_callback(exit_cond_obj);    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);
pike.git/src/threads.c:1889:    if(!thread_local_prog)    Pike_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);    thread_storage_offset=ADD_STORAGE(struct thread_state);    PIKE_MAP_VARIABLE("result", OFFSETOF(thread_state, result),    tMix, T_MIXED, 0); -  /* function(mixed ...:void) */ +     ADD_FUNCTION("create",f_thread_create,    tFuncV(tNone,tMixed,tVoid),    ID_STATIC); -  /* function(:array) */ +     ADD_FUNCTION("backtrace",f_thread_backtrace,tFunc(tNone,tArray),0); -  /* function(:mixed) */ +     ADD_FUNCTION("wait",f_thread_id_result,tFunc(tNone,tMix),0); -  /* function(:int) */ +     ADD_FUNCTION("status",f_thread_id_status,tFunc(tNone,tInt),0);    ADD_FUNCTION("_sprintf",f_thread_id__sprintf,tFunc(tNone,tStr),0);    ADD_FUNCTION("id_number",f_thread_id_id_number,tFunc(tNone,tInt),0);    set_gc_recurse_callback(thread_was_recursed);    set_gc_check_callback(thread_was_checked);    set_init_callback(init_thread_obj);    set_exit_callback(exit_thread_obj);    thread_id_prog=Pike_compiler->new_program;    thread_id_prog->flags |= PROGRAM_NO_EXPLICIT_DESTRUCT;    add_ref(thread_id_prog);    end_class("thread_id", 0);       /* Backward compat... */    add_global_program("thread_create", thread_id_prog);    -  /* function(:object(Pike_interpreter.thread_id)) */ +     ADD_EFUN("this_thread",f_this_thread,    tFunc(tNone,tObjIs_THREAD_ID),    OPT_EXTERNAL_DEPEND);    -  /* function(:array(object(Pike_interpreter.thread_id))) */ +     ADD_EFUN("all_threads",f_all_threads,    tFunc(tNone,tArr(tObjIs_THREAD_ID)),    OPT_EXTERNAL_DEPEND);       /* Some constants... */    add_integer_constant("THREAD_NOT_STARTED", THREAD_NOT_STARTED, 0);    add_integer_constant("THREAD_RUNNING", THREAD_RUNNING, 0);    add_integer_constant("THREAD_EXITED", THREAD_EXITED, 0);       if(!mutex_key)