Branch: Tag:

1998-03-26

1998-03-26 05:48:24 by Per Hedbor <ph@opera.com>

Added _threads_disallow(). Returns a key object.

Rev: src/threads.c:1.64

1:   #include "global.h" - RCSID("$Id: threads.c,v 1.63 1998/03/25 18:53:09 grubba Exp $"); + RCSID("$Id: threads.c,v 1.64 1998/03/26 05:48:24 per Exp $");      int num_threads = 1;   int threads_disabled = 0;
152:    struct array *args;   };    - int threads_denied; + void exit_threads_disable(struct object *o) + { +  if(threads_disabled) threads_disabled--; + }    - void f_thread_disallow(INT32 args) + void init_threads_disable(struct object *o)   { -  threads_denied = sp[-1].u.integer; -  pop_n_elems(args); +  threads_disabled++;   }      /* Thread hashtable */
279:    static int div_;    if(div_++ & 255) return;    -  if(!threads_denied) -  { +     THREADS_ALLOW(); -  +     /* Allow other threads to run */ -  +     THREADS_DISALLOW();   } - } +       void *new_thread_func(void * data)   {
742:      #endif    -  add_efun("thread_disallow", f_thread_disallow, "function(int:void)", -  OPT_SIDE_EFFECT); -  +     add_efun("thread_create",f_thread_create,"function(mixed ...:object)",    OPT_SIDE_EFFECT);   #ifdef UNIX_THREADS
789:    set_exit_callback(exit_cond_obj);    end_class("condition", 0);    +  { +  struct program *tmp;    start_new_program(); -  +  set_init_callback(init_threads_disable); +  set_exit_callback(exit_threads_disable); +  tmp = end_program(); +  tmp->flags|=PROGRAM_DESTRUCT_IMMEDIATE; +  add_global_program("_disable_threads", tmp); +  } +  +  start_new_program();    add_storage(sizeof(struct thread_state));    thread_id_result_variable=simple_add_variable("result","mixed",0);    add_function("backtrace",f_thread_backtrace,"function(:array)",0);