Parallel Programming with OmniThreadLibrary
Parallel Programming with OmniThreadLibrary
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
The Book
PDF
EPUB
WEB
English
The Book + Webinars
This package contains the book and three hour-long webinars on using high-level multithreading abstractions.
Includes:
High-Level Multithreading with OmniThreadLibrary
This is a collection of three one-hour webinars on using high-level multithreading abstractions in the OmniThreadLibrary.
PDF
EPUB
WEB
English
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.
Includes:
High-Level Multithreading with OmniThreadLibrary
This is a collection of three one-hour webinars on using high-level multithreading abstractions in the OmniThreadLibrary.
PDF
EPUB
WEB
English
Table of Contents
- About me
- Credits
-
Introduction
- Formatting conventions
- Learn more
- Release notes
-
1. Introduction to multi-threading
-
1.1 Multi-threading as a source of problems
- 1.1.1 Reading and writing shared data
- 1.1.2 Modifying shared data
- 1.1.3 Writes masquerading as reads
-
1.1 Multi-threading as a source of problems
-
2. Introduction to OmniThreadLibrary
- 2.1 Requirements
- 2.2 License
-
2.3 Installation
- 2.3.1 Installing with GetIt
- 2.3.2 Installing with Delphinus
- 2.3.3 Installing design package
- 2.4 Why use OmniThreadLibrary?
- 2.5 Tasks vs. threads
- 2.6 Locking vs. messaging
-
2.7 Message loop required
- 2.7.1 OmniThreadLibrary and console
- 2.7.2 OmniThreadLibrary task started from another task
- 2.7.3 OmniThreadLibrary task started from a TThread
-
2.8 TOmniValue
- 2.8.1 Data access
- 2.8.2 Type testing
- 2.8.3 Clearing the content
- 2.8.4 Operators
- 2.8.5 Using with generic types
- 2.8.6 Array access
- 2.8.7 Handling records
- 2.8.8 Object ownership
- 2.8.9 Working with TValue
- 2.8.10 Low-level methods
- 2.9 TOmniValueObj
- 2.10 Fluent interfaces
-
3. High-level multi-threading
-
3.1 Introduction
- 3.1.1 A life cycle of an abstraction
- 3.1.2 Anonymous methods, procedures, and methods
- 3.1.3 Pooling
-
3.2 Blocking collection
- 3.2.1 IOmniBlockingCollection
- 3.2.2 Bulk import and export
- 3.2.3 Throttling
- 3.3 Task configuration
-
3.4 Async
- 3.4.1 Handling exceptions
- 3.5 Async/Await
-
3.6 Future
- 3.6.1 IOmniFuture<T> interface
- 3.6.2 Completion detection
- 3.6.3 Cancellation
- 3.6.4 Handling exceptions
- 3.6.5 Examples
-
3.7 Join
- 3.7.1 IOmniParallelJoin interface
- 3.7.2 IOmniJoinState interface
- 3.7.3 Cancellation
- 3.7.4 Handling exceptions
-
3.8 Parallel task
- 3.8.1 IOmniParallelTask interface
- 3.8.2 Example
- 3.8.3 Handling exceptions
- 3.8.4 Examples
-
3.9 Background worker
- 3.9.1 Basics
- 3.9.2 IOmniBackgroundWorker interface
- 3.9.3 Task initialization
- 3.9.4 Work item configuration
- 3.9.5 Work item interface
- 3.9.6 Examples
-
3.10 Pipeline
- 3.10.1 Background
- 3.10.2 Basics
-
3.10.3 IOmniPipeline interface
- 3.10.3.1 Example
- 3.10.4 Generators, mutators, and aggregators
- 3.10.5 Throttling
- 3.10.6 Parallel stages
- 3.10.7 Exceptions
- 3.10.8 Examples
-
3.11 Parallel for
- 3.11.1 IOmniParallelSimpleLoop interface
- 3.11.2 Iterating over an array
- 3.11.3 Examples
-
3.12 ForEach
- 3.12.1 Cooperation
-
3.12.2 Iterating 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.3 Providing external input
- 3.12.4 IOmniParallelLoop interface
- 3.12.5 Preserving output order
- 3.12.6 Aggregation
- 3.12.7 Cancellation
- 3.12.8 Task initialization and finalization
- 3.12.9 Handling exceptions
- 3.12.10 Examples
-
3.13 Fork/Join
- 3.13.1 IOmniForkJoin interface
- 3.13.2 IOmniCompute interface
- 3.13.3 IOmniCompute<T> interface
- 3.13.4 Exceptions
- 3.13.5 Examples
-
3.14 Map
- 3.14.1 IOmniParallelMapper<T1,T2> interface
-
3.15 Timed task
- 3.15.1 IOmniTimedTask interface
-
3.1 Introduction
-
4. Low-level multi-threading
- 4.1 Low-level for the impatient
- 4.2 Four ways to create a task
- 4.3 IOmniTaskControl and IOmniTask interfaces
- 4.4 Task controller needs an owner
- 4.5 Communication subsystem
- 4.6 Processor groups and NUMA nodes
-
4.7 Thread pooling
- 4.7.1 Execution flow
- 4.7.2 IOmniThreadPool interface
- 4.7.3 Task exit code
- 4.7.4 Monitoring thread pool operations
- 4.7.5 Processor groups and NUMA nodes
-
4.8 Lock-free collections
- 4.8.1 Bounded Stack
- 4.8.2 Bounded queue
- 4.8.3 Message queue
- 4.8.4 Dynamic queue
-
4.8.5 Observing lock-free collections
- 4.8.5.1 Examples
- 4.8.6 Benchmarks
- 4.9 Event monitor
-
4.10 Simple tasks
- 4.10.1 Name
- 4.10.2 UniqueID
- 4.10.3 Parameters
- 4.10.4 Termination
- 4.10.5 ExitCode
- 4.10.6 Exceptions
- 4.10.7 Sending messages to a task
- 4.10.8 Receiving messages from a task
- 4.10.9 ChainTo
- 4.10.10 Join / Leave
- 4.10.11 MonitorWith / RemoveMonitor
- 4.10.12 Enforced
- 4.10.13 Unobserved
- 4.10.14 Cancellation token / CancelWith
- 4.10.15 Lock / WithLock
- 4.10.16 WithCounter
- 4.10.17 SetPriority
- 4.10.18 SetQueueSize
-
4.11 TOmniWorker tasks
- 4.11.1 WaitForInit
- 4.11.2 Task
- 4.11.3 Receiving messages
- 4.11.4 RegisterComm
- 4.11.5 Invoke
- 4.11.6 Windows message & APC processing
- 4.11.7 Timers
- 4.11.8 TerminateWhen
- 4.11.9 UserData
- 4.12 Task groups
-
4.13 IOmniTask interface
- 4.13.1 Name and ID
- 4.13.2 Parameters
- 4.13.3 Termination
- 4.13.4 Exit status
- 4.13.5 Exceptions
- 4.13.6 Communication
- 4.13.7 Timers
- 4.13.8 RegisterWaitObject
- 4.13.9 CancellationToken
- 4.13.10 Lock
- 4.13.11 Counter
- 4.13.12 Processor groups and NUMA nodes
- 4.13.13 Internal and obsolete functions
-
5. Synchronization
-
5.1 Critical sections
- 5.1.1 IOmniCriticalSection
- 5.1.2 TOmniCS
-
5.1.3 Locked<T>
- 5.1.3.1 Why not use TMonitor?
- 5.2 TOmniMREW
- 5.3 Cancellation token
- 5.4 Waitable value
- 5.5 Inverse semaphore
-
5.6 Initialization
- 5.6.1 Pessimistic initialization
- 5.6.2 Optimistic initialization
- 5.7 TWaitFor
- 5.8 TOmniLockManager<K>
- 5.9 TOmniSingleThreadUseChecker
-
5.1 Critical sections
-
6. Miscellaneous
- 6.1 TOmniTwoWayChannel
- 6.2 TOmniValueContainer
- 6.3 TOmniCounter
- 6.4 TOmniAlignedInt32 and TOmniAlignedInt64
- 6.5 TOmniRecordWrapper
- 6.6 TOmniRecord
- 6.7 IOmniAutoDestroyObject
- 6.8 IOmniIntegerSet
-
6.9 Environment
- 6.9.1 IOmniAffinity
-
7. How-to
- 7.1 Background file scanning
- 7.2 Web download and database storage
- 7.3 Parallel for with synchronized output
- 7.4 Using taskIndex and task initializer in parallel for
- 7.5 Background worker and list partitioning
- 7.6 Parallel data production
-
7.7 Building a connection pool
- 7.7.1 From theory to practice
- 7.7.2 Running the demo
-
7.8 QuickSort and parallel max
- 7.8.1 QuickSort
- 7.8.2 Parallel max
- 7.9 Parallel search in a tree
-
7.10 Multiple workers with multiple frames
- 7.10.1 The worker
- 7.10.2 The frame
- 7.10.3 The form
-
7.11 OmniThreadLibrary and databases
- 7.11.1 Database model
-
7.11.2 Frame and worker
- 7.11.2.1 Connecting to the database
- 7.11.2.2 Retrieving the data
- 7.11.3 Main program
- 7.12 OmniThreadLibrary and COM/OLE
-
7.13 Using a message queue with a TThread worker
-
7.13.1 Sending data from multiple producers to a single worker
- 7.13.1.1 Initialization and cleanup
- 7.13.1.2 Sending data to the worker
- 7.13.1.3 Receiving the data
-
7.13.2 Sending data from a worker to a form
- 7.13.2.1 Initialization and cleanup
- 7.13.2.2 Sending data to the form
- 7.13.2.3 Receiving the data
-
7.13.1 Sending data from multiple producers to a single worker
- 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
- Notes
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.
See full terms
80% Royalties. Earn $16 on a $20 book.
We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earned$12,307,240writing, 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
Top Books
OpenIntro Statistics
David Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntroA complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
Personal Finance
Jason AndersonThis textbook provides an in-depth analysis on personal finance that is both practical and straightforward in its approach. It has been written in such a way that the readers can gain knowledge without getting overwhelmed by the technical terms. Suitable for both beginners and advanced learners.
Getting to Know IntelliJ IDEA
Trisha Gee and Helen ScottIf we treat our IDE as a text editor, we are doing ourselves a disservice. Using a combination of tutorials and a questions-and-answers approach, Getting to Know IntelliJ IDEA will help you find ways to use IntelliJ IDEA that enable you to work comfortably and productively as a professional developer.
C++20 - The Complete Guide
Nicolai M. JosuttisAll new language and library features of C++20 (for those who know previous C++ versions).
The book presents all new language and library features of C++20. Learn how this impacts day-to-day programming, to benefit in practice, to combine new features, and to avoid all new traps.
Buy early, pay less, free updates.
Other books:
Mastering STM32 - Second Edition
Carmine NovielloWith more than 1200 microcontrollers, STM32 is probably the most complete ARM Cortex-M platform on the market. This book aims to be the most complete guide around introducing the reader to this exciting MCU portfolio from ST Microelectronics and its official CubeHAL and STM32CubeIDE development environment.
R Programming for Data Science
Roger D. PengThis book brings the fundamentals of R programming to you, using the same material developed as part of the industry-leading Johns Hopkins Data Science Specialization. The skills taught in this book will lay the foundation for you to begin your journey learning data science. Printed copies of this book are available through Lulu.
Machine Learning Q and AI
Sebastian Raschka, PhDHave you recently completed a machine learning or deep learning course and wondered what to learn next? With 30 questions and answers on key concepts in machine learning and AI, this book provides bite-sized bits of knowledge for your journey to becoming a machine learning expert.
Stats One
William FooteThe Rails 7 Way
Obie Fernandez, Lucas Dohmen, and Tom Henrik AadlandThe Rails™ 7 Way is the comprehensive, authoritative reference guide for professionals delivering production-quality code using modern Ruby on Rails. It illuminates the entire Rails 7 API, its most powerful idioms, design approaches, and libraries. Building on the previous editions, this edition has been heavily refactored and updated.
Gradual Modularization for Ruby and Rails
Stephan HagemannGet yourself a new tool to manage your Rails application and your growing engineering organization! Prevent the ball-of-mud (and fix it!). Go for microservices or SOA if it makes sense not just because you don't have any other tool. Do all this through a low-overhead tool: packages. Enable better conversations to make practical changes today.
Top Bundles
- #1
Software Architecture
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before... - #2
CCIE Service Provider Ultimate Study Bundle
2 Books
Piotr Jablonski, Lukasz Bromirski, and Nick Russo have joined forces to deliver the only CCIE Service Provider training resource you'll ever need. This bundle contains a detailed and challenging collection of workbook labs, plus an extensively detailed technical reference guide. All of us have earned the CCIE Service Provider certification... - #3
1500 QUIZ COMMENTATI (3 libri)
3 Books
Tre libri dei QUIZ MMG Commentati al prezzo di DUE! I QUIZ dei concorsi ufficiali di Medicina Generale relativi agli anni: 2000-2001-2003-2012-2013-2014-2015-2016-2017-2018-2019-2020-2021 +100 inediti Raccolti in unico bundle per aiutarvi nello studio e nella preparazione al concorso. All'interno di ogni libro i quiz sono stati suddivisi per... - #4
Pattern-Oriented Memory Forensics and Malware Detection
2 Books
This training bundle for security engineers and researchers, malware and memory forensics analysts includes two accelerated training courses for Windows memory dump analysis using WinDbg. It is also useful for technical support and escalation engineers who analyze memory dumps from complex software environments and need to check for possible... - #5
Practical FP in Scala + Functional event-driven architecture
2 Books
Practical FP in Scala (A hands-on approach) & Functional event-driven architecture, aka FEDA, (Powered by Scala 3), together as a bundle! The content of PFP in Scala is a requirement to understand FEDA so why not take advantage of this bundle!? - #6
Modern C++ Collection
3 Books
Get All about Modern C++C++ Standard Library, including C++20Concurrency with Modern C++, including C++20C++20Each book has about 200 complete code examples. Updates are included. When I update one of the books, you immediately get the updated bundle. You can expect significant updates to each new C++ standard (C++23, C++26, .. ) and also... - #7
Linux Administration Complet
4 Books
Ce lot comprend les quatre volumes du Guide Linux Administration :Linux Administration, Volume 1, Administration fondamentale : Guide pratique de préparation aux examens de certification LPIC 1, Linux Essentials, RHCSA et LFCS. Administration fondamentale. Introduction à Linux. Le Shell. Traitement du texte. Arborescence de fichiers. Sécurité... - #9
Development and Deployment of Multiplayer Online Games, Part ARCH. Architecture (Vol. I-III)
3 Books
What's the Big Idea? The idea behind this book is to summarize the body of knowledge that already exists on multiplayer games but is not available in one single place.And quite a fewof the issues discussed within this series (planned as three nine volumes ~300 pages each), while known in the industry, have not been published at all (except for... - #10
Growing Agile: The Complete Coach's Guide
7 Books
Growing Agile: Coach's Guide Series This bundle provides a collection of training and workshop plans for a variety of agile topics. The series is aimed at agile coaches, trainers and ScrumMasters who often find themselves needing to help teams understand agile concepts. Each book in the series provides the plans, slides, handouts and activity...