Tuesday, October 11, 2011

OmniThreadLibrary 2.2

Only three months since 2.1 and a new release is already here? What’s going on?

I had to change some things to make OTL work in XE2 and although I could simply release new files as a patch I noticed that I’ve also done quite some work on exception handling and that I could equally well wrap everything in a new release.

Here it is: ZIP, SVN, UML diagrams (provided by Rich Shealer; Rich, thanks!).

There were some breaking changes since the 2.1 release so let’s start with those …

Breaking Changes

  • Parallel.Join reimplemented as IOmniParallelJoin interface to add exception and cancellation support. User code must call .Execute on the interface returned from the Parallel.Join to
    start the execution. [read more]
  • Parallel.Join(const task: TOmniTaskDelegate) is no longer supported. It was replaced with the Parallel.Join(const task: IOmniJoinState).
  • Parallel.Join no longer supports taskConfig parameter (replaced by the IOmniParallelJoin.TaskConfig function).
  • Two versions of Parallel.Async (the ones with explicit termination handlers) were removed as this functionality can be achieved by using Parallel.TaskConfig.OnTerminated. [read more]

New Features

  • Delphi XE2 support (Windows 32-bit only).
  • Parallel.Task can be used to execute multiple copies of a common code. [read more]
  • Added exception handling to Parallel.Join. Tasks' fatal exceptions are wrapped in EJoinException and raised at the end of Parallel.Join method (or when WaitFor is called if Join is executed with the .NoWait modifier). [read more]
  • Number of simultaneously executed task in Parallel.Join may be set by calling the new IOmniParallelJoin.NumTasks function.
  • Added exception handling to IOmniFuture<T>. Tasks' fatal exception is raised in .Value. New function .FatalException and .DetachException. [read more]
  • Implemented TOmni[Base]Queue.IsEmpty. Keep in mind that the returned value may not be valid for any amount of time if other threads are reading from/writing to the queue.
  • Implemented another IOmniTaskControl.OnTerminated overload accepting parameterless anonymous function.
  • Implemented [I|T]OmniBlockingCollection.IsFinalized.
  • Parallel.Pipeline accepts 'simple stage' (for loop implemented internally). [read more]
  • TOmniValue can natively store exception objects (AsException, IsException).
  • Implemented IOmniBlockingCollection.ReraiseExceptions. If enabled (default: disabled), [Try]Take will check if returned value for exception (TOmniValue.IsException) and if true, it will reraise this exception instead of returning a result.
  • Assertions are enabled in OTLOptions.inc - OtlContainers needs them.

Bug Fixes

  • Event monitor in connection to the thread pool was totally broken. (Big thanks to [anton alisov] for finding the problem.)
  • Fixed [Try]Add/CompleteAdding/[Try]Take three-thread race condition in TOmniBlockingCollection. [read more]

New Demos  

  • 48_OtlParallelExceptions: Exception handling in high-level OTL constructs.

6 comments:

  1. Anonymous13:51

    All of your READ MORE links end with a ] character, which makes the links 404.

    ReplyDelete
  2. Hi! Any plans to implement OTL on OS X / Win64 ? What are difficulties to go to new platform? Can you share your plans?)

    ReplyDelete
  3. Plans are to implement Win64 support "soon" (before the end of the year) and OS/X "later" (no definite plans yet).

    Win64 will be simple, just some changes in the assembler.

    OS/X will be harder as I don't have any way to test OS/X code at the moment. Anybody wants to donate a Mac?

    ReplyDelete
  4. Anonymous09:04

    I can send a VM... cheap and easy

    ReplyDelete
  5. @Anonymous ... but not really legal. (I can find VM myself, but still thanks!)

    ReplyDelete
  6. Hello Gabr, sorry for spam.
    Could you please judge my humble parallel for implementation on the http://vitaliburkov.wordpress.com/2011/10/15/parallel-programming-in-delphi/
    Any thoughts/comments/critics will be appreciated.

    ReplyDelete