[Lazarus] local procedure - MultiThreadProc

Mattias Gaertner nc-gaertnma at netcologne.de
Wed Aug 19 20:44:05 CEST 2009


On Wed, 19 Aug 2009 17:33:59 +0200
Florian Klaempfl <florian at freepascal.org> wrote:

> Mattias Gärtner schrieb:
> > Zitat von Vincent Snijders <vsnijders at vodafonevast.nl>:
> > 
> >> Martin schreef:
> >>> Mattias Gärtner wrote:
> >>>> Zitat von Jan Kowalski <bor400 at gmail.com>:
> >>>>> I need to call ProcThreadPool.DoParallel with "local" procedure
> >>>>> as a parameter.
> >>>>> Does DoParallel allow local procedures to pass a procedural 
> >>>>> parameters ?
> >>>>> I get err: Error:
> >>>>> Incompatible type for arg no. 1: Got "<address of local
> >>>>> procedure(Int64,Pointer,TMultiThreadProcItem);Register>",
> >>>>> expected "<procedure variable type of
> >>>>> procedure(Int64,Pointer,TMultiThreadProcItem);Register>"
> >>>>
> >>>> That would be really helpful.
> >>>> But I don't know how to define a local procedure type:
> >>>>
> >>> I wouldn't be sure it's possible. It makes no sense.
> > 
> > It makes enough sense in this case.
> > For example when you want to execute a loop in parallel, then you 
> > extract the loop into a procedure. With a local procedure you can
> > keep the variables, which would make the process quite easy. If you
> > can not use a local procedure, then you must define a record and
> > move the local variables there.
> > Of course nested local procedures creates a whole bunch of
> > problems, so maybe the record approach is much safer.
> > Maybe the extract procedure tool can be extended to do some of the 
> > monotone work automatically.
> > I will explain the process in more detail on the wiki.
> 
> You can create a thread call for local procedures, it needs some
> hacking though: no type checking is possible, you've to work with
> pointers and pass the context explicitly.

Can you give an example?

Mattias




More information about the Lazarus mailing list