200 likes | 315 Vues
Explore the intricacies of high-level multithreaded programming with Primož Gabrijelčič in this comprehensive webinar series. Learn about OmniThreadLibrary, high-level abstractions like ParallelTask, BackgroundWorker, and Pipeline. Understand the considerations for data flow in parallel coding and how to effectively utilize multithreading to optimize your software. Each session provides valuable coding examples and insights, helping you master the art of multithreading in Delphi. Join us and enhance your programming skills today!
E N D
High-level Multithreaded Programming [Part III] Primož Gabrijelčič
About Me • Primož Gabrijelčič • Programmer, consultant, writer, speaker • thedelphigeek.com • www.glagolite.si/delphi • Hacking multithreaded code since 1999
About OmniThreadLibrary • „VCL for multithreading“ • Delphi 2007 – XE3[4] • Open source – OpenBSD license • www.omnithreadlibrary.com • omnithreadlibrary.googlecode.com • Win32/Win64
About the Webinars • Code and video: www.omnithreadlibrary.com/webinars • Code = free, video = $10 • 20 free books, courtesy of the De Novo Software, www.denovosoftware.com
High-Level Abstractions • ParallelTask • BackgroundWorker • Pipeline • ForkJoin • Async [/Await] • Future • Join • ForEach
Which abstraction to use? • Consider data flow!
High-Level Abstractions • ParallelTask • BackgroundWorker • ForkJoin • Pipeline • Async [/Await] • Future • Join • ForEach • Parallel iteration over data
Iterate over … • Integer range • Enumerable collection (TStringList …) • Thread-safe enumerable collection (OTL) • Blocking collection (IOmniBlockingCollection) • Anything • Custom enumerator function • Main program writing into a blocking collection
Special features • Synchronized access to data • Data prefetching • Work stealing • Optional output ordering • Aggregation
Aggregation aggregate := initial value for each value in source Execute(value, result) if not result.IsEmpty then Agreggator(aggregate, value)
Demos • 35_ParallelFor • 36_ParallelAggregate • 38_OrderedFor
High-Level Abstractions • ParallelTask • BackgroundWorker • ForkJoin • Pipeline • Async [/Await] • Future • Join • ForEach • Parallelization of multistage operations
Keep in Mind • Don’t parallelize everything • Rethink the algorithm • Data flow dictates the abstraction • Measure the improvements • Test, test and test
Code • Will be available shortly at www.omnithreadlibrary.com/webinars