> At 2:29 AM -0700 7/18/06, Artur Bergman wrote:
> >On Jul 18, 2006, at 2:15 AM, Elizabeth Mattijsen wrote:
> >
> >>At 2:07 AM -0700 7/18/06, Artur Bergman wrote:
> >>>On Jul 18, 2006, at 1:52 AM, Elizabeth Mattijsen wrote:
> >>>
> >>>>Trying to do this by override CORE::exit is not a option, as you 
> >>>>can only do this at compile time (as far as I know).
> >>>>
> >>>>So I would favour in extra, cloned global variable that would be 
> >>>>checked by CORE::Exit, which would indicate whether to really 
> >>>>exit(), or do a threads->exit().  And have an easy way to change 
> >>>>the (cloned) setting of this variable with a threads class 
> >>>>method, e.g. thread->exit_exits_thread_only;
> >>>
> >>>You can use CORE::exit if you make sure you set it before you load 
> >>>the external module.
> >>
> >>True, but generally you just "use" code in your program, which 
> >>means the code is used by the main thread already, before you start 
> >>the thread.
> >>
> >>Which is the reason I once wrote Thread::Use.
> >
> >if you use a module that changes CORE::exit before you use any other 
> >module you are set to go.
> 
> Well, that's what the "threads" module should do then.

Let's get the requirements down before we worry about implementation,
shall we, folks.  (From what I envision, there will be no need to mess
with CORE::exit for these changes - it can all be done in threads.xs.)

First of all, do we have a consensus on changing anything?  I think so: 
Rafeal, Artur, Liz and Jan are in favor of the general concept of exit()
terminating the app, and threads->exit() terminating the thread.  Any
dissensions?

Next is the question of this being overridable such that exit() can be
made to just terminate just the thread.  Liz and Artur are in on this. 
Others?

Assuming overriding is allowed, my suggestion for design would be to
have both of the following:

1. Global basis:
    use threads 'exit' => 'threads_only';
      # or just
    use threads 'exit' => 'threads';

2. Per thread basis:  
    my $thr = threads->create({'exit' => 'thread_only'}, 'thr_func',
...);
      # or just
    my $thr = threads->create({'exit' => 'thread'}, 'thr_func', ...);

(Implementation can most easily be handled by adding a flag to the
threads structure in threads.xs, and action would taken accordingly
after trapping an 'exitting' thread.)


Reply via email to