[fpc-devel] Suggestion: reference counted objects

Boian Mitov mitov at mitov.com
Mon Sep 22 22:07:11 CEST 2014


BTW: Please note that since you can keep adding executions to the task, it 
can be done in nested loops, as well as in function calls thus doing fully 
fledged parallelization.
The executor also can be single thread, unlimited threads, self balancing, 
or limited pool depending on the specific instance, so a very fine control 
can be exercised over the execution, as well as it can be changed 
dynamically by code, thus sometime executing the code with one executor and 
other times with another, based on the specific needs.

Adding simple parallel loop lacks any of this power, and only serves very 
specific cases.

With best regards,
Boian Mitov

-------------------------------------------------------
Mitov Software
www.mitov.com
-------------------------------------------------------
-----Original Message----- 
From: Boian Mitov
Sent: Monday, September 22, 2014 11:54 AM
To: FPC developers' list
Subject: Re: [fpc-devel] Suggestion: reference counted objects

Here is example from our implementation:

for AIndex := 0 to Length( AList ) - 1 do
  AExecutionTask.Add(
      FExecutor.Execute(
          TDelegate.Capture<Integer>( AIndex,
              procedure( ALocalIndex : Integer )
              begin
                Sleep( 1000 ); // Simulate thread busy doing time consuming
task
                AList[ ALocalIndex ] := ALocalIndex * 2;
              end
            )
        )
    );

AExecutionTask.WaitFor();



With best regards,
Boian Mitov

-------------------------------------------------------
Mitov Software
www.mitov.com
-------------------------------------------------------




More information about the fpc-devel mailing list