Delphi Event-based and Asynchronous Programming - The Book / Contact

Delphi Event-based and Asynchronous Programming

Please select your option

Use Coupon Code: DTSPATTxx at checkout to get a $10 discount.
This promotional offer is valid through June 14.

Delphi Thread Safety Patterns

291 pages PDF, ePub, mobi

While the thread safety of a particular piece of code depends on the surrounding context and how it is used, some data types are inherently unsafe, and for some of them, thread safety will depend on the use case and the specific code. Unfortunately, when you look at some class, type declaration, or API in isolation, there is very little information there that will tell you whether instances of that type can be safely used in multiple threads, or under which conditions.

The proper place to learn about the thread safety of an API is its documentation. However, most documentation will not explicitly give you that information. Occasionally, the documentation will mention that a particular feature is not thread-safe, or will tell you that a feature can be used in background threads, but for the most part, you will have to figure out thread safety on your own. One reason for this is that thread safety depends on the context. The number of features that are absolutely unsafe or are absolutely safe is very small.

The basic thread safety rules are simple, but applying those rules is more complicated. Just as design patterns give us general solutions to common coding problems, we can extract common coding patterns from various multithreaded code—thread safety patterns.

This book converts the thread safety rules into practice, and gives an overview of core Delphi frameworks and commonly used features from a thread safety perspective. You will find examples of how particular classes can be used in a thread-safe manner and how to perform some common tasks, following the already established thread safety patterns.

Besides elaborating on the thread safety of particular parts of Delphi frameworks, the book explores the thread safety of alternate solutions, along with general coding examples. Every explanation about why some code is thread-safe or not, also serves as an example of thread (un)safety patterns, and helps in recognizing thread-unsafe code, as well as establishing a working set of thread safety patterns that can later be applied in custom code.

Those examples, covering the most commonly used parts of Delphi frameworks, will also serve as learn by example pointers for determining the thread safety of other parts of the frameworks, and even of 3rd-party libraries that are not specifically covered in this book.

There are also implementations and examples of some commonly used concepts in asynchronous programming that are not part of the core Delphi frameworks, but can be indispensable when writing multithreaded code.


Table of Contents


Part 1. Thread Safety

* Language and general thread safety

* Proving thread safety

* Examples

   + Data type thread safety
   + Thread-safe data types used in an unsafe manner 
   + Code thread safety

Part 2. The Core Run-Time Library

* Global state

* Floating-point control register

* FormatSettings and formatting routines

* Global functions and procedures

   + Parameters
   + FreeAndNil
   + Class methods
   + Other global functions

* Class fields, singletons, and default instances

   + Class constructors and initialization section
   + Thread-safe lazy initialization
   + Writeable instances

* Core classes

   + Core classes
   + Custom classes

* Threads

   + FreeOnTerminate
   + Starting a thread
   + Order of destruction
   + Custom thread's data

* Streams

* Collections

   + Making a thread-safe variant of a thread-unsafe collection
   + Thread-safe iteration
   + Partial locking
   + False sense of the security
   + Wrappers vs inheritance
   + Immutable collections

* Parallel collection processing

* Components

   + Using components in background threads
   + Component streaming


Part 3. Core Frameworks

* Serialization

   + Protecting the Data
     - Unshared data
     - Read-only data
     - Mutable data protected by a synchronization mechanism
   + Protecting the serializer
     - Function, procedure or class method
     - Stateless or immutable serializer instance
     - Stateful serializer instance
   + Net encoding classes
   + JSON
   + XML

* System.Net

* Asynchronous Programming Library

* Indy


* Regular expressions

Part 4. Visual Frameworks - VCL and FMX

* Visual framework components

* LiveBindings

* VCL and FMX controls

* Interactions with OS APIs and frameworks

   + Window allocation and de-allocation
   + Windows messaging
   + Timers

Part 5. Graphics and Image Processing

* Graphics and image processing

   + Graphics and image processing
   + Graphics platforms and frameworks

* Resource consumption

* Common graphics types and API

* VCL graphics types and API

   + Fonts, pens, and brushes
   + Canvas
   + Graphics
   + Picture
   + Vcl.GraphUtil
   + VCL image collections

* VCL graphics example

* FMX graphics types and API

Part 6. Custom Frameworks

* Writing custom frameworks

* Logging

* Cancellation tokens

* Event bus

* Measuring performance


* References

* Quality Portal Reports


Important Note:
If you purchased Part I of the book before December 27, you can download the Full version now, through the same PDF/epub/mobi links that you have received earlier from FastSpring via email.
The subject line of that email message was: "Your Delphi Event-based and Asynchronous Programming - Part I Delivery Information"


If you have already purchased the eBook version, and wish to buy the paperback, you're eligible for a 50% discount! You will find the discount code with instructions in the eBook order confirmation email.Contact us to get a discount code and a link.


Copyright © Prasnikar.info / Terms / Privacy / Contact