Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiDemoFiremonkeyIOSOSXWindows

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.

Related posts
AndroidC++BuilderCode SnippetDelphiDemoFiremonkeyIOSOSXShowcaseWindows

Powerful Cross Platform Email App Sample In Delphi 10.4.1 FireMonkey For Android And IOS

AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

Significant Update Available For Delphi FireMonkey 10.4.1 On Android, IOS, OSX, Windows, And Linux

C++BuilderDelphiIDEWindows

Professional SVG Icon Image List For Delphi 10.4 FireMonkey On Windows

AndroidC++BuilderDelphiFiremonkeyIOSLiveBindingsOSXWindows

Top Tips And Tricks To Speed Up Development With Delphi 10.4 FireMonkey On Android and IOS

Sign up for our Newsletter and
stay informed

Leave a Reply