Zitat von Luca Olivetti <[EMAIL PROTECTED]>:

> En/na Mattias Gärtner ha escrit:
> > I'm writing a unit to simplify parallel methods/procedures.
> >
> > For example:
> >   DoParallel(@AMethod,StartIndex,EndIndex,Data);
> >
> > The AMethod is executed with several threads in parallel.
> >
> > What should happen when an exception occurs?
>
> AFAIK any unhandled exception in a thread will cause it to silently die

Yes, and that should never happen. At least not for normal exceptions like out
of memory, index out of bounds, io error - anything that does not corrupt the
heap.
I'm catching any exception. But somehow the exception must be delegated to the
group's starter thread. (which is not necessarily the process' main thread).


> > It would be nice if the exception can be transfered to the main thread.
> > Is this possible? How?
>
> I don't know, set a flag in the thread and check it periodically from
> the main thread?

I do that already.
My current idea is to simply pass the exception object to the other thread and
raise it there. But I'm not sure if this works always. Maybe I have to set some
more RTL values to do that cleanly.


> (Florian's suggestion does the reverse: raise in a thread an exception
> occurred while executing in the context of the main thread)

Yes, but 'synchronize' is only for the process' main thread.

Mattias

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to