Parallel Programming with OmniThreadLibrary
Parallel programming is hard. Your best bet to a stable application is a good multithreading framework and for Delphi that means OmniThreadLibrary. This book will guide you through all parts of this complex library and help you write great applications that will use all CPU power available in modern computers.
About
About the Book
Parallel programming is hard. Your best bet to a stable application is a good multithreading framework and for Delphi that means OmniThreadLibrary (www.omnithreadlibrary.com).
This book - which is, incidentally, written by the very author of the OmniThreadLibrary - walks you through different parts of the library. It gives an overview of low-level multithreading approach (programming with tasks), high-level approach (programming with abstractions) and describes various helper functions and data structures implemented in the library.
The book also walks you through multiple examples which demonstrate different aspects of multithreaded programming - from parallel execution of http requests to creation of database connection pools and multithreaded user interfaces.
A printed version is available on Lulu. If you'd like to buy both electronic and paper edition, buy the printed version first as that will give you a coupon for the e-book.
Packages
Pick Your Package
All packages include the ebook in the following formats: PDF, EPUB, and Web
The Book
Minimum price
Suggested price$29.99$29.99
The Book + Webinars
Minimum price
Suggested price$39.99This package contains the book and three hour-long webinars on using high-level multithreading abstractions.
$34.99
- High-Level Multithreading with OmniThreadLibraryThis is a collection of three one-hour webinars on using high-level multithreading abstractions in the OmniThreadLibrary.
This book is also available in the following packages:
Organisation License (unlimited use)
Unlimited copies for 1) staff members employed by the purchasing organisation, and for educational organisations, 2) for every registered student of the purchasing organisation. Also contains three webinars.
- High-Level Multithreading with OmniThreadLibraryThis is a collection of three one-hour webinars on using high-level multithreading abstractions in the OmniThreadLibrary.
- Minimum price
- $250.00
- Suggested price
- $250.00
- High-Level Multithreading with OmniThreadLibrary
Author
About the Author
Primož Gabrijelčič
Primož Gabrijelčič is a long-time Delphi programmer, writer for The Delphi Magazine, Monitor, and Blaise Pascal magazines and frequent contributor to the Delphi-SI community. His Delphi-related ramblings are collected on the The Delphi Geek blog.
In his long career he has produced several open-source projects such as Delphi profiler GpProfile (now maintained by others). His active projects include OmniThreadLibrary, a multithreading library for Delphi and several open-sourced Delphi tools, published in the GpDelphiUnits repository.
Contents
Table of Contents
About me
Credits
Introduction
- Formatting conventions
- Learn more
Release notes
1.Introduction to multi-threading
- 1.1Multi-threading as a source of problems
- 1.1.1Reading and writing shared data
- 1.1.2Modifying shared data
- 1.1.3Writes masquerading as reads
2.Introduction to OmniThreadLibrary
- 2.1Requirements
- 2.2License
- 2.3Installation
- 2.3.1Installing with GetIt
- 2.3.2Installing with Delphinus
- 2.3.3Installing design package
- 2.4Why use OmniThreadLibrary?
- 2.5Tasks vs. threads
- 2.6Locking vs. messaging
- 2.7Message loop required
- 2.7.1OmniThreadLibrary and console
- 2.7.2OmniThreadLibrary task started from another task
- 2.7.3OmniThreadLibrary task started from a TThread
- 2.8TOmniValue
- 2.8.1Data access
- 2.8.2Type testing
- 2.8.3Clearing the content
- 2.8.4Operators
- 2.8.5Using with generic types
- 2.8.6Array access
- 2.8.7Handling records
- 2.8.8Object ownership
- 2.8.9Working with TValue
- 2.8.10Low-level methods
- 2.9TOmniValueObj
- 2.10Fluent interfaces
3.High-level multi-threading
- 3.1Introduction
- 3.1.1A life cycle of an abstraction
- 3.1.2Anonymous methods, procedures, and methods
- 3.1.3Pooling
- 3.2Blocking collection
- 3.2.1IOmniBlockingCollection
- 3.2.2Bulk import and export
- 3.2.3Throttling
- 3.3Task configuration
- 3.4Async
- 3.4.1Handling exceptions
- 3.5Async/Await
- 3.6Future
- 3.6.1IOmniFuture<T> interface
- 3.6.2Completion detection
- 3.6.3Cancellation
- 3.6.4Handling exceptions
- 3.6.5Examples
- 3.7Join
- 3.7.1IOmniParallelJoin interface
- 3.7.2IOmniJoinState interface
- 3.7.3Cancellation
- 3.7.4Handling exceptions
- 3.8Parallel task
- 3.8.1IOmniParallelTask interface
- 3.8.2Example
- 3.8.3Handling exceptions
- 3.8.4Examples
- 3.9Background worker
- 3.9.1Basics
- 3.9.2IOmniBackgroundWorker interface
- 3.9.3Task initialization
- 3.9.4Work item configuration
- 3.9.5Work item interface
- 3.9.6Examples
- 3.10Pipeline
- 3.10.1Background
- 3.10.2Basics
- 3.10.3IOmniPipeline interface
- 3.10.3.1Example
- 3.10.4Generators, mutators, and aggregators
- 3.10.5Throttling
- 3.10.6Parallel stages
- 3.10.7Exceptions
- 3.10.8Examples
- 3.11Parallel for
- 3.11.1IOmniParallelSimpleLoop interface
- 3.11.2Iterating over an array
- 3.11.3Examples
- 3.12ForEach
- 3.12.1Cooperation
- 3.12.2Iterating over …
- 3.12.2.1… Number ranges
- 3.12.2.2… Enumerable collections
- 3.12.2.3… Thread-safe enumerable collections
- 3.12.2.4… Blocking collections
- 3.12.2.5… Anything
- 3.12.3Providing external input
- 3.12.4IOmniParallelLoop interface
- 3.12.5Preserving output order
- 3.12.6Aggregation
- 3.12.7Cancellation
- 3.12.8Task initialization and finalization
- 3.12.9Handling exceptions
- 3.12.10Examples
- 3.13Fork/Join
- 3.13.1IOmniForkJoin interface
- 3.13.2IOmniCompute interface
- 3.13.3IOmniCompute<T> interface
- 3.13.4Exceptions
- 3.13.5Examples
- 3.14Map
- 3.14.1IOmniParallelMapper<T1,T2> interface
- 3.15Timed task
- 3.15.1IOmniTimedTask interface
4.Low-level multi-threading
- 4.1Low-level for the impatient
- 4.2Four ways to create a task
- 4.3IOmniTaskControl and IOmniTask interfaces
- 4.4Task controller needs an owner
- 4.5Communication subsystem
- 4.6Processor groups and NUMA nodes
- 4.7Thread pooling
- 4.7.1Execution flow
- 4.7.2IOmniThreadPool interface
- 4.7.3Task exit code
- 4.7.4Monitoring thread pool operations
- 4.7.5Processor groups and NUMA nodes
- 4.8Lock-free collections
- 4.8.1Bounded Stack
- 4.8.2Bounded queue
- 4.8.3Message queue
- 4.8.4Dynamic queue
- 4.8.5Observing lock-free collections
- 4.8.5.1Examples
- 4.8.6Benchmarks
- 4.9Event monitor
- 4.10Simple tasks
- 4.10.1Name
- 4.10.2UniqueID
- 4.10.3Parameters
- 4.10.4Termination
- 4.10.5ExitCode
- 4.10.6Exceptions
- 4.10.7Sending messages to a task
- 4.10.8Receiving messages from a task
- 4.10.9ChainTo
- 4.10.10Join / Leave
- 4.10.11MonitorWith / RemoveMonitor
- 4.10.12Enforced
- 4.10.13Unobserved
- 4.10.14Cancellation token / CancelWith
- 4.10.15Lock / WithLock
- 4.10.16WithCounter
- 4.10.17SetPriority
- 4.10.18SetQueueSize
- 4.11TOmniWorker tasks
- 4.11.1WaitForInit
- 4.11.2Task
- 4.11.3Receiving messages
- 4.11.4RegisterComm
- 4.11.5Invoke
- 4.11.6Windows message & APC processing
- 4.11.7Timers
- 4.11.8TerminateWhen
- 4.11.9UserData
- 4.12Task groups
- 4.13IOmniTask interface
- 4.13.1Name and ID
- 4.13.2Parameters
- 4.13.3Termination
- 4.13.4Exit status
- 4.13.5Exceptions
- 4.13.6Communication
- 4.13.7Timers
- 4.13.8RegisterWaitObject
- 4.13.9CancellationToken
- 4.13.10Lock
- 4.13.11Counter
- 4.13.12Processor groups and NUMA nodes
- 4.13.13Internal and obsolete functions
5.Synchronization
- 5.1Critical sections
- 5.1.1IOmniCriticalSection
- 5.1.2TOmniCS
- 5.1.3Locked<T>
- 5.1.3.1Why not use TMonitor?
- 5.2TOmniMREW
- 5.3Cancellation token
- 5.4Waitable value
- 5.5Inverse semaphore
- 5.6Initialization
- 5.6.1Pessimistic initialization
- 5.6.2Optimistic initialization
- 5.7TWaitFor
- 5.8TOmniLockManager<K>
- 5.9TOmniSingleThreadUseChecker
6.Miscellaneous
- 6.1TOmniTwoWayChannel
- 6.2TOmniValueContainer
- 6.3TOmniCounter
- 6.4TOmniAlignedInt32 and TOmniAlignedInt64
- 6.5TOmniRecordWrapper
- 6.6TOmniRecord
- 6.7IOmniAutoDestroyObject
- 6.8IOmniIntegerSet
- 6.9Environment
- 6.9.1IOmniAffinity
7.How-to
- 7.1Background file scanning
- 7.2Web download and database storage
- 7.3Parallel for with synchronized output
- 7.4Using taskIndex and task initializer in parallel for
- 7.5Background worker and list partitioning
- 7.6Parallel data production
- 7.7Building a connection pool
- 7.7.1From theory to practice
- 7.7.2Running the demo
- 7.8QuickSort and parallel max
- 7.8.1QuickSort
- 7.8.2Parallel max
- 7.9Parallel search in a tree
- 7.10Multiple workers with multiple frames
- 7.10.1The worker
- 7.10.2The frame
- 7.10.3The form
- 7.11OmniThreadLibrary and databases
- 7.11.1Database model
- 7.11.2Frame and worker
- 7.11.2.1Connecting to the database
- 7.11.2.2Retrieving the data
- 7.11.3Main program
- 7.12OmniThreadLibrary and COM/OLE
- 7.13Using a message queue with a TThread worker
- 7.13.1Sending data from multiple producers to a single worker
- 7.13.1.1Initialization and cleanup
- 7.13.1.2Sending data to the worker
- 7.13.1.3Receiving the data
- 7.13.2Sending data from a worker to a form
- 7.13.2.1Initialization and cleanup
- 7.13.2.2Sending data to the form
- 7.13.2.3Receiving the data
A. Units
B. Demo applications
C. Examples
D. Hooking into OmniThreadLibrary
- Exception notifications
- Thread notifications
- Pool notifications
E. ForEach internals
- Source provider
- Data manager
- Local queue
- Output ordering
F. Hyperlinks
Get the free sample chapters
Click the buttons to get the free sample in PDF or EPUB, or read the sample online here
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Write and Publish on Leanpub
You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!
Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.