Tuesday, July 19, 2011

OmniThreadLibrary 2.1

Yes, it is ready. Get the ZIP or check it from SVN.

If you’re following the trunk, do the update. You’ll actually get more than 2.1 as I’ve already merged in development branch with support for exception handling in Parallel.Future and Parallel.Join. Warning – those changes may break the code as two version of Parallel.Async were removed. Check the history.txt and documentation in OtlParallel.pas for more info.

This time you can also download full UML diagrams for OmniThreadLibrary, courtesy of Rich Shealer.

2.1 release should be mostly non-breaking, except for changes in OtlHook exception filtering mechanism and removed EXIT_EXCEPTION exit code (see below for more info).

I’d like to thank dottor_jeckill, Rico Krasowski, vcldeveloper and TOndrej, who helped make this release even more awesomer.

This is not just a bugfix release so let’s start with …

New Features

  • New high-level tool Parallel.Async can be used to start simple background tasks. [read more]
  • New high-level tool Parallel.ForkJoin simplifies development of divide and conquer (fork/join) algorithms. [read more]
  • OtlParallel tasks can be configured with Parallel.TaskConfig. You can also use TaskConfig to communicated with the owner thread from task. [read more]
  • IOmniTask and IOmniTaskControl implement Invoke method which you can use to asynchronously execute a block of code in the other thread. [read more]
  • Timer methods can specify timerID: TOmniValue parameter. ID of the timer is passed to this parameter which enables you to share one method between many timers.
  • Support for non-silent exceptions was removed, together with the EXIT_EXCEPTION exit code. All exceptions caught at the IOmniTask level (i.e. not handled in your task code) are now stored in the IOmniTaskControl.FatalException property. You can call IOmniTaskControl.DetachException to take ownership of this exception object.
  • Changed signature for exception filters in OtlHook.FilterException.
  • IOmniTaskControl termination empties task message queue and calls appropriate OnMessage handlers.

Bug Fixes

  • Fixed race condition in TOmniTask.Execute.
  • OtlParallel compiles in Delphi 2009.
  • Fixed: OTL monitor message window could be used after it was destroyed.
  • Fixed: Parallel.ForEach was never running on more than Process.Affinity.Count tasks.
  • OtlParallel pools are created on the fly – OtlParallel unit can now be used from a DLL.
  • [dottor_jeckill] Fixed: TOmniResourceCount.TryAllocate always returned False.
  • Fixed: Enumerating over TOmniTaskControlList (for example when using IOmniTaskGroup.SendToAll) leaked one object.
  • Makes sure timers are called even if there's a constant stream of messages in registered message queues.
  • Fixed exception handling in the thread pool.

New Demos

  • 43_InvokeAnonymous: Demo for IOmniTaskControl.Invoke and IOmniTask.Invoke.
  • 44_Fork-Join QuickSort: QuickSort implemented with Parallel.ForkJoin.
  • 45_Fork-Join max: Selecting maximum element in an array using Parallel.ForkJoin.
  • 46_Async: Demo for Parallel.Async.
  • 47_TaskConfig: Demo for Parallel.TaskConfig.

Have fun using OmniThreadLibrary and kudos to first five downloaders who grabbed their copy even before I managed to publish this blog :)

OTL 2.1 download


  1. Cristiano Narcisi (dottor_jeckill)10:06

    Thanks for your great work.

    I'm downloading the new release and I start the testing immediately.

    Have a nice day.

    Bye bye.

  2. Thanks for the release, Primoz! For sure, you'll change the Delphi world :)

  3. hi

    good code with no documented then totally not usable !

  4. What is the omnithread thing, and can I use it in Delphi 7?

    Kind regards, Nils

  5. @mellobot, see http://otl.17slon.com/faq.htm