[Lazarus] delphi - virus
Martin
lazarus at mfriebe.de
Fri Aug 21 00:19:28 CEST 2009
On Wed, 19 Aug 2009 20:52:41 +0200
Florian Klaempfl <florian at freepascal.org> wrote:
> Mattias Gaertner schrieb:
> >> 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?
>
> See
> http://www.freepascal.org/docs-html/rtl/objects/callpointerlocal.html
>
> and e.g. the comment of Jonas:
> (0014130)
> Jonas Maebe (manager)
> 2007-08-13 15:02
> at http://bugs.freepascal.org/view.php?id=9432
Cool. It really works, at least under linux 32bit. I wonder on what
other platforms this will work.
I added it to mtprocs. Now you can do:
procedure DoSomething(Value: PtrInt);
var
p: array[1..2] of Pointer;
procedure SubProc(Index: PtrInt; Data: Pointer; Item: TMultiThreadProcItem);
begin
p[Index]:=Pointer(Value);
end;
var
i: Integer;
begin
ProcThreadPool.DoParallelLocalProc(@SubProc,1,2);
end;
This avoids splitting and produces much more readable code.
Mattias
More information about the Lazarus
mailing list