Keep Threading in Mind

by Apr 22, 2017

In my interview with Martin he talked a lot about the importance of performance, which is one of the reasons he uses Delphi for his real-time lighting control systems. He said something along the lines that if you are not programming with threading in mind then you are never going to get good performance. That is good advice. Even cell phones have quad-core processors in them these days.

Keep Threading in Mind

 

Delphi includes a great Parallel Programming Library which I really like. There is also the ever popular OmniThreadLibrary. They both make parallel programming much easier. I just learned about a new helper library to make parallel programming even easier.

CocinAsync: A Delphi library to simplify coding and improve performance of asynchronous and multithreaded applications.

It includes a number of different units and helpers. According to Jason Southwell, the developer, he has found a “100 to 150% improvement in performance over equivalent generic container wrapped in a critical section.” So how does it do this? If you look at the page the first thing you see is a brilliant couple helpers: QueueIfInThread & SynchronizeIfInThread.

We all know it is important to make sure certain code is synchronized into the main thread, unfortunately we end up with multiple code paths some and some code could be executed in the main thread via one call, and a background thread in another call. Using this helper only performs the synchronization if the code was called from a background thread.

That is just one of the helper classes included in CocinAsync. Take a look at it and keep threading in mind.