> >Doing this properly with data sources you completely control in a 
> >multi-access situation (read: with threads) is *hard*.
> 
> Is it?
> 
> Here's some high-level emulation of what it should do.
> 
>       eval {
>               my($_a, $_b, $c) = ($a, $b, $c);
>               ...
>               ($a, $b, $c) = ($_a, $_b, $_c);
>       }
> 
> Now, "all" that needs to be taken care of, is make sure that the final
> assignment from the localized and changed variables to their
> outer-scoped counterparts happens in *one step*, i.e. no task switching
> while this is going on.

Well, that can't be done.  (I assume that by 'task switching' you mean
here 'thread switching') Or, if it can, it *shouldn't* be done.
Threads run on their own until they yield, they decide to synchronize
and/or join, or they exit.  Note the "they decide".  There is no
central switchboard from where you can control 'your threads'.  Sure,
you could make all your threads to go through a central
synchronization point 'often enough, say, in the op dispatch loop, but
that's going to be rather costly.  You can do all kinds of tricks with
e.g. thread priorities, yes, but you cannot and you should not try to
control trask switching.  A 'yield' is the closest you can do, and
that's just a kind note to the scheduler, not a command.

> -- 
>       Bart.

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen

Reply via email to