[fpc-devel] Suggestion: reference counted objects
Boian Mitov
mitov at mitov.com
Sun Sep 21 04:55:13 CEST 2014
Hmm.... the last time I checked this was anonymous methods... Are you sure I was talking closures?
FThread1.Process(
procedure()
var
ANewText1 : String;
begin
Sleep( 500 ); // Simulate thread busy doing time consuming task
ANewText1 := AText + ' + Thread1';
FThread2.Process(
procedure()
var
ANewText2 : String;
begin
Sleep( 500 ); // Simulate thread busy doing time consuming task
ANewText2 := ANewText1 + ' + Thread2';
FThread3.Process(
procedure()
var
ANewText3 : String;
begin
Sleep( 500 ); // Simulate thread busy doing time consuming task
ANewText3 := ANewText2 + ' + Thread3';
FThread4.Process(
procedure()
var
ANewText4 : String;
begin
Sleep( 500 ); // Simulate thread busy doing time consuming task
ANewText4 := ANewText3 + ' + Thread4';
MainThreadExecute(
False
,
procedure()
begin
Memo1.Lines.Add( 'Ended Processing: ' + ACounter.ToString() + ' - Result:' );
Memo1.Lines.Add( ANewText4 );
Memo1.Lines.Add( '' );
Dec( FInProccessingCount );
Label1.Caption := 'In processing pipeline = ' + FInProccessingCount.ToString();
end
);
end
);
end
);
end
);
end
);
This is a 4 stage pipeline with asynchronous main thread printing.
I dare somebody to implement it in less than 5-6 times more code with traditional methods, and while matching the performance...
With best regards,
Boian Mitov
-------------------------------------------------------
Mitov Software
www.mitov.com
-------------------------------------------------------
From: Dmitry Boyarintsev
Sent: Saturday, September 20, 2014 7:46 PM
To: FPC developers' list
Subject: Re: [fpc-devel] Suggestion: reference counted objects
To be more accurate..
You're talking about "closures". The difference between closures and anonymous functions is explained here: http://en.wikipedia.org/wiki/Closure_(computer_programming)#History_and_etymology the second paragraph.
thanks,
Dmitry
--------------------------------------------------------------------------------
_______________________________________________
fpc-devel maillist - fpc-devel at lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20140920/88a0f670/attachment.html>
More information about the fpc-devel
mailing list