Leanpub Header

Skip to main content

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.

Minimum price

$29.99

$29.99

You pay

$29.99

Author earns

$23.99

Packages

Details
$

...Or Buy With Credits!

You can get credits monthly with a Reader Membership
PDF
EPUB
WEB
801
Readers
304
Pages
About

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.

Share this book

Categories

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.99

    This package contains the book and three hour-long webinars on using high-level multithreading abstractions.

    $34.99

    • High-Level Multithreading with OmniThreadLibrary
      This 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 OmniThreadLibrary
        This 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

    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

    1. Formatting conventions
    2. Learn more

    Release notes

    1.Introduction to multi-threading

    1. 1.1Multi-threading as a source of problems
    2. 1.1.1Reading and writing shared data
    3. 1.1.2Modifying shared data
    4. 1.1.3Writes masquerading as reads

    2.Introduction to OmniThreadLibrary

    1. 2.1Requirements
    2. 2.2License
    3. 2.3Installation
    4. 2.3.1Installing with GetIt
    5. 2.3.2Installing with Delphinus
    6. 2.3.3Installing design package
    7. 2.4Why use OmniThreadLibrary?
    8. 2.5Tasks vs. threads
    9. 2.6Locking vs. messaging
    10. 2.7Message loop required
    11. 2.7.1OmniThreadLibrary and console
    12. 2.7.2OmniThreadLibrary task started from another task
    13. 2.7.3OmniThreadLibrary task started from a TThread
    14. 2.8TOmniValue
    15. 2.8.1Data access
    16. 2.8.2Type testing
    17. 2.8.3Clearing the content
    18. 2.8.4Operators
    19. 2.8.5Using with generic types
    20. 2.8.6Array access
    21. 2.8.7Handling records
    22. 2.8.8Object ownership
    23. 2.8.9Working with TValue
    24. 2.8.10Low-level methods
    25. 2.9TOmniValueObj
    26. 2.10Fluent interfaces

    3.High-level multi-threading

    1. 3.1Introduction
    2. 3.1.1A life cycle of an abstraction
    3. 3.1.2Anonymous methods, procedures, and methods
    4. 3.1.3Pooling
    5. 3.2Blocking collection
    6. 3.2.1IOmniBlockingCollection
    7. 3.2.2Bulk import and export
    8. 3.2.3Throttling
    9. 3.3Task configuration
    10. 3.4Async
    11. 3.4.1Handling exceptions
    12. 3.5Async/Await
    13. 3.6Future
    14. 3.6.1IOmniFuture<T> interface
    15. 3.6.2Completion detection
    16. 3.6.3Cancellation
    17. 3.6.4Handling exceptions
    18. 3.6.5Examples
    19. 3.7Join
    20. 3.7.1IOmniParallelJoin interface
    21. 3.7.2IOmniJoinState interface
    22. 3.7.3Cancellation
    23. 3.7.4Handling exceptions
    24. 3.8Parallel task
    25. 3.8.1IOmniParallelTask interface
    26. 3.8.2Example
    27. 3.8.3Handling exceptions
    28. 3.8.4Examples
    29. 3.9Background worker
    30. 3.9.1Basics
    31. 3.9.2IOmniBackgroundWorker interface
    32. 3.9.3Task initialization
    33. 3.9.4Work item configuration
    34. 3.9.5Work item interface
    35. 3.9.6Examples
    36. 3.10Pipeline
    37. 3.10.1Background
    38. 3.10.2Basics
    39. 3.10.3IOmniPipeline interface
    40. 3.10.3.1Example
    41. 3.10.4Generators, mutators, and aggregators
    42. 3.10.5Throttling
    43. 3.10.6Parallel stages
    44. 3.10.7Exceptions
    45. 3.10.8Examples
    46. 3.11Parallel for
    47. 3.11.1IOmniParallelSimpleLoop interface
    48. 3.11.2Iterating over an array
    49. 3.11.3Examples
    50. 3.12ForEach
    51. 3.12.1Cooperation
    52. 3.12.2Iterating over …
    53. 3.12.2.1… Number ranges
    54. 3.12.2.2… Enumerable collections
    55. 3.12.2.3… Thread-safe enumerable collections
    56. 3.12.2.4… Blocking collections
    57. 3.12.2.5… Anything
    58. 3.12.3Providing external input
    59. 3.12.4IOmniParallelLoop interface
    60. 3.12.5Preserving output order
    61. 3.12.6Aggregation
    62. 3.12.7Cancellation
    63. 3.12.8Task initialization and finalization
    64. 3.12.9Handling exceptions
    65. 3.12.10Examples
    66. 3.13Fork/Join
    67. 3.13.1IOmniForkJoin interface
    68. 3.13.2IOmniCompute interface
    69. 3.13.3IOmniCompute<T> interface
    70. 3.13.4Exceptions
    71. 3.13.5Examples
    72. 3.14Map
    73. 3.14.1IOmniParallelMapper<T1,T2> interface
    74. 3.15Timed task
    75. 3.15.1IOmniTimedTask interface

    4.Low-level multi-threading

    1. 4.1Low-level for the impatient
    2. 4.2Four ways to create a task
    3. 4.3IOmniTaskControl and IOmniTask interfaces
    4. 4.4Task controller needs an owner
    5. 4.5Communication subsystem
    6. 4.6Processor groups and NUMA nodes
    7. 4.7Thread pooling
    8. 4.7.1Execution flow
    9. 4.7.2IOmniThreadPool interface
    10. 4.7.3Task exit code
    11. 4.7.4Monitoring thread pool operations
    12. 4.7.5Processor groups and NUMA nodes
    13. 4.8Lock-free collections
    14. 4.8.1Bounded Stack
    15. 4.8.2Bounded queue
    16. 4.8.3Message queue
    17. 4.8.4Dynamic queue
    18. 4.8.5Observing lock-free collections
    19. 4.8.5.1Examples
    20. 4.8.6Benchmarks
    21. 4.9Event monitor
    22. 4.10Simple tasks
    23. 4.10.1Name
    24. 4.10.2UniqueID
    25. 4.10.3Parameters
    26. 4.10.4Termination
    27. 4.10.5ExitCode
    28. 4.10.6Exceptions
    29. 4.10.7Sending messages to a task
    30. 4.10.8Receiving messages from a task
    31. 4.10.9ChainTo
    32. 4.10.10Join / Leave
    33. 4.10.11MonitorWith / RemoveMonitor
    34. 4.10.12Enforced
    35. 4.10.13Unobserved
    36. 4.10.14Cancellation token / CancelWith
    37. 4.10.15Lock / WithLock
    38. 4.10.16WithCounter
    39. 4.10.17SetPriority
    40. 4.10.18SetQueueSize
    41. 4.11TOmniWorker tasks
    42. 4.11.1WaitForInit
    43. 4.11.2Task
    44. 4.11.3Receiving messages
    45. 4.11.4RegisterComm
    46. 4.11.5Invoke
    47. 4.11.6Windows message & APC processing
    48. 4.11.7Timers
    49. 4.11.8TerminateWhen
    50. 4.11.9UserData
    51. 4.12Task groups
    52. 4.13IOmniTask interface
    53. 4.13.1Name and ID
    54. 4.13.2Parameters
    55. 4.13.3Termination
    56. 4.13.4Exit status
    57. 4.13.5Exceptions
    58. 4.13.6Communication
    59. 4.13.7Timers
    60. 4.13.8RegisterWaitObject
    61. 4.13.9CancellationToken
    62. 4.13.10Lock
    63. 4.13.11Counter
    64. 4.13.12Processor groups and NUMA nodes
    65. 4.13.13Internal and obsolete functions

    5.Synchronization

    1. 5.1Critical sections
    2. 5.1.1IOmniCriticalSection
    3. 5.1.2TOmniCS
    4. 5.1.3Locked<T>
    5. 5.1.3.1Why not use TMonitor?
    6. 5.2TOmniMREW
    7. 5.3Cancellation token
    8. 5.4Waitable value
    9. 5.5Inverse semaphore
    10. 5.6Initialization
    11. 5.6.1Pessimistic initialization
    12. 5.6.2Optimistic initialization
    13. 5.7TWaitFor
    14. 5.8TOmniLockManager<K>
    15. 5.9TOmniSingleThreadUseChecker

    6.Miscellaneous

    1. 6.1TOmniTwoWayChannel
    2. 6.2TOmniValueContainer
    3. 6.3TOmniCounter
    4. 6.4TOmniAlignedInt32 and TOmniAlignedInt64
    5. 6.5TOmniRecordWrapper
    6. 6.6TOmniRecord
    7. 6.7IOmniAutoDestroyObject
    8. 6.8IOmniIntegerSet
    9. 6.9Environment
    10. 6.9.1IOmniAffinity

    7.How-to

    1. 7.1Background file scanning
    2. 7.2Web download and database storage
    3. 7.3Parallel for with synchronized output
    4. 7.4Using taskIndex and task initializer in parallel for
    5. 7.5Background worker and list partitioning
    6. 7.6Parallel data production
    7. 7.7Building a connection pool
    8. 7.7.1From theory to practice
    9. 7.7.2Running the demo
    10. 7.8QuickSort and parallel max
    11. 7.8.1QuickSort
    12. 7.8.2Parallel max
    13. 7.9Parallel search in a tree
    14. 7.10Multiple workers with multiple frames
    15. 7.10.1The worker
    16. 7.10.2The frame
    17. 7.10.3The form
    18. 7.11OmniThreadLibrary and databases
    19. 7.11.1Database model
    20. 7.11.2Frame and worker
    21. 7.11.2.1Connecting to the database
    22. 7.11.2.2Retrieving the data
    23. 7.11.3Main program
    24. 7.12OmniThreadLibrary and COM/OLE
    25. 7.13Using a message queue with a TThread worker
    26. 7.13.1Sending data from multiple producers to a single worker
    27. 7.13.1.1Initialization and cleanup
    28. 7.13.1.2Sending data to the worker
    29. 7.13.1.3Receiving the data
    30. 7.13.2Sending data from a worker to a form
    31. 7.13.2.1Initialization and cleanup
    32. 7.13.2.2Sending data to the form
    33. 7.13.2.3Receiving the data

    A. Units

    B. Demo applications

    C. Examples

    D. Hooking into OmniThreadLibrary

    1. Exception notifications
    2. Thread notifications
    3. Pool notifications

    E. ForEach internals

    1. Source provider
    2. Data manager
    3. Local queue
    4. 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.

    Learn more about writing on Leanpub