Branch: Tag:

2000-01-31

2000-01-31 16:31:36 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Try to avoid recursive mutex enter errors.

Rev: lib/modules/Thread.pmod:1.19

21: Inside #if constant(thread_create)
   mixed read()    {    mixed tmp; -  object key=lock::lock(); +  object key=lock::lock(2);    while(!num) r_cond::wait(key);    tmp=buffer[ptr];    buffer[ptr++] = 0; // Throw away any references.
40: Inside #if constant(thread_create)
   array read_array()    {    array ret; -  object key=lock::lock(); +  object key=lock::lock(2);    while(!num) r_cond::wait(key);    if(num==1)    {
59: Inside #if constant(thread_create)
      void write(mixed v)    { -  object key=lock::lock(); +  object key=lock::lock(2);    while(num == sizeof(buffer)) w_cond::wait(key);    buffer[(ptr + num) % sizeof(buffer)]=v;    if(write_tres)
91: Inside #if constant(thread_create)
   mixed read()    {    mixed tmp; -  object key=lock::lock(); +  object key=lock::lock(2);    while(!size()) r_cond::wait(key);    tmp=buffer[r_ptr];    buffer[r_ptr++] = 0; // Throw away any references.
101: Inside #if constant(thread_create)
      void write(mixed v)    { -  object key=lock::lock(); +  object key=lock::lock(2);    if(w_ptr >= sizeof(buffer))    {    buffer=buffer[r_ptr..];
171: Inside #if constant(thread_create)
   static class Handler    {    Condition cond = Condition(); -  array job; +  array(object|array(function|array)) job;    object thread;       float total_time;
181: Inside #if constant(thread_create)
      void handler()    { -  array q; +  array(object|array(function|array)) q;    while( 1 )    {    ready = 1;
191: Inside #if constant(thread_create)
   mixed res, err;    int st = gethrtime();    if( err = catch(res = q[1][0]( @q[1][1] )) && q[0]) -  q[0]->provide_error( err ); +  ([object]q[0])->provide_error( err );    else if( q[0] ) -  q[0]->provide( res ); +  ([object]q[0])->provide( res );    object lock = mutex->lock();    free_threads += ({ this_object() });    lock = 0;
215: Inside #if constant(thread_create)
   }    }    -  void run( array what, object|void resobj ) +  void run( array(function|array) what, object|void resobj )    {    while(!ready) sleep(0.1);    job = ({ resobj, what });
267: Inside #if constant(thread_create)
   mutex->lock();    }    } -  object t = free_threads[0]; +  object(Handler) t = free_threads[0];    free_threads = free_threads[1..];    return t;    }
275: Inside #if constant(thread_create)
      static void dispatcher()    { -  while( array q = job_queue->read() ) +  while( array q = [array]job_queue->read() )    aquire_thread()->run( q[1], q[0] );    }   
287: Inside #if constant(thread_create)
      void go(mixed vn, int err)    { -  r->value[ i ] = vn; +  ([array]r->value)[ i ] = vn;    if( err )    r->provide_error( err );    if( !--v->num_left )