Fast Threaded Parallel For Loop In Delphi XE7 Firemonkey On Android, IOS, Windows, And OSX

Delphi XE7 Firemonkey Parallel For LoopDavid Intersimone from Embarcadero has a blog post up which highlights more information about the new parallel programming library which ships with Delphi XE7 Firemonkey. The parallel functions work across all platforms (Android, IOS, OSX, and Windows). From what I understand about the library it has a built in thread pool which the various functions use on the back end to reduce resource usage. There are three blog posts which David I. references by Stephen Ball from Embarcadero where he demonstrates TParallel, TTask, and IFuture. Basically what TParallel.For probably does is take the function that you pass to it and spawn it off in it’s own separate thread. Each time the loop iterates it spawns off a new thread until I assume there is one thread for each CPU (for example 4 threads for a 4 CPU mobile device). Once the work in a thread is complete it goes back into the pool for use later. If you have Delphi XE5 or Delphi XE6 you can check out this custom parallel option. I tested the Conway Game Of Life demo that comes with Delphi XE7 and with parallel mode on it did go at 4X the speed on a 4 CPU X86 machine. I also tested just the straight TParallel.For loop with adding items to a TListView (which you should not do). It did work but it was not thread safe. Here is the sample from Stephen Bell’s blog post (notice how it uses TInterlocked.Increment to increment a number in parallel in a thread safe fashion):

Head over and check out the full blog post with all of the links to info about the new TParallel.For loop in Delphi XE7 Firemonkey.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

One Response to Fast Threaded Parallel For Loop In Delphi XE7 Firemonkey On Android, IOS, Windows, And OSX

  1. Pingback: How To Utilize Asynchonous Futures In Delphi XE7 Firemonkey On Android And IOS | Delphi XE5 XE6 XE7 Firemonkey, Delphi Android, Delphi IOS

Leave a Reply

Show Buttons
Hide Buttons
Read previous post:
Customize OpenGL GPU Settings For Delphi XE6 And XE7 Firemonkey Apps On Android And IOS

Buried near the bottom of the Delphi XE6 release notes is this tidbit on overridding the OpenGL rendering parameters to...