Thursday, July 06, 2017

OmniThreadLibrary 3.07.2

This is just a small update which adds few helpful methods. Although the change log mentions a potentially breaking change I don't think this will affect anybody. (And if you are not sure, you can enabled backward-compatible behaviour by adding one line to the code.)

I have also (finally) found some time to work on The book. It is now fully up to date (all OmniThreadLibrary features are documented on its whooping 293 pages) and is only missing one or two introductory chapters.

As usual, you can get OmniThreadLibrary from GitHub (3.07.2, HEAD), download the zip, install it with GetIt (soon, I hope) or with Delphinus (already).

Change log follows after the break.

  • Potentially breaking change
    • Cancel(taskID) will signal task's cancellation token before calling task's Terminate method. CancelAll will signal cancellation token for all running tasks before calling their Terminate method.
      Old behaviour (no CancellationToken.Signal before Terminate) can be achieved by calling overloaded version of the functions accepting the `signalCancellationToken` parameter or by setting IOmniThreadPool.Options to [tpoPreventCancellationTokenOnCancel].
  • New features
    • Added OnStop overload that accepts 'reference to procedure (const task: IOmniTask)' to Parallel.Join and Parallel.ParallelTask.
    • Added OnStopInvoke to all Parallel abstractions that implement OnStop method.
      • IOmniParallelLoop.OnStopInvoke and IOmniParallelMapper are only available on XE7 and newer compilers.
    • Added IOmniTaskConfig.NoThreadPool. This allows high-level abstractions to bypass thread pool entirely and run in 'non-pooled' threads.
    • TOmniCS.Initialize uses global lock to synchronize initialization instead of a CAS operation. This fixes all reasons for the infamous error "TOmniCS.Initialize: XXX is not properly aligned!".
  • Bug fixes
    • Parallel.Future did not create task with the .Unobserved qualifier.
  • New demos
    • 66_ThreadsInThreads: Demonstrates how to manage OTL threads from other OTL threads and from TThread threads.


  1. Thanks, Primoz! NoThreadPool looks promising. Could you please give a bit more detailed description of difference in behavior with and without thread pool (how thread pool affects OTL high level abstractions).

    1. Part of this is explained in the book: Do you need any additional information?