Saturday, October 27, 2012

ITDevCon–Recap

The ITDevCon 2012 is over and I’m back at home, resting and gathering impressions.

The conference was even better organized than previous years and everything was running as smooth as possible (with the small exception of the projector in the main hall, which somehow was not capable of giving out a completely sharp picture). In addition to the multinational group of speakers, the visitors also came from variety of countries – I noticed four Germans, two Russians and a Lituanian – which plays well with the intentions of making the ITDevCon the biggest European conference.

As usual, the conference took two full days, with five session timeslots on the first and six on the second day. At every time there were three parallel talks going on, some in Italian and some in English.

I’ve given three presentations – general tutorial on regular expressions and two “hands-on” sessions in problem/solution format – one on Windows + OS X development and another on OmniThreadLibrary. Slides and sample code are available on my blog.

I also listened to few sessions – both talks by Jeroen Pluimers were full of information and very useful; Ray Konopka’s session on user interfaces was incredible as always, Paweł Głowacki showed us what can be done with FireMonkey 3D components and Jørn E. Angeltveit gave interesting (WAT!) talk about the Smart Mobile Studio. I’m just too sory that I couldn’t follow Ray’s talk on creating custom controls for FireMonkey … Still, every session was recorded and participants will be able to get recordings of sessions they have missed. (By the way, recordings of last year conference are available on line.) I was also happy to finally meet Detlef Overbeek, the main guy behind the Blaise Pascal Magazine.

A quick shout to people that I haven’t yet mentioned – it was great to talk to you!

I would like to thank the organizer for inviting me again to the beautiful Verona and for all the great food we were able to taste in the two conference days (and at the pre-conference dinner). See you next year, guys!

Friday, October 26, 2012

Thursday, October 25, 2012

ITDevCon Photos

Just a few photo impressions from the conference …

bitTime Teambooksbooks2DanieleDetlefJeroenJornMarco, Pawel and Fabriziovisitors

Tuesday, October 23, 2012

Generating Reports with Background Worker

Long time ago, in August, JimVern asked on the OmniThreadLibrary forum:

I am creating a Windows Service to handle report requests for our clients.  Each client has multiple users who may run a report.  I want to serialize the report requests for one client so that only one report will run for a client at a time (FIFO), but reports can run simultaneously for different clients.

Since users can submit report requests anytime, I need to be able to append a new request to the end of an existing client FIFO queue without interrupting the execution of the current report.  Or, if the client doesn't have a queue yet (e.g., it's the first report request), then I need to be able to add a client queue without disrupting any reports running for other clients.  Once a client queue is empty, I want to destroy the client queue.

I am new to OTL, but it looks like it will easily do what I need. I'm just not sure where to focus my attention. Is there a way to create named task groups that can execute the top task of each group simultaneously, where tasks can be appended to an existing group, and where groups can auto-terminate when the tasks are all executed? Perhaps there an example project or a similar post that I can look at to get started? I'm still somewhat of a novice when it comes to threads, so any advise is also welcome.

My answer at that time was just a pointer in the correct direction:

Instead of running multiple tasks for one client, why don't you consider running one task per client and sending workload requests to that task?

You could then schedule each such task into a thread pool. The task would run in a loop and process requests. When it runs out of requests, it would shut down. The main program would be responsible for starting a new task if not already running. [There's a small race condition here - you would have to maintain a shared structure enumerating live tasks that would be modified from the task code and from the main program and it would have to be locked-accessed.]

I promised Jim a working solution but then I got lost in all sorts of other, more important projects and it was only few days ago that I was able to finish the job. Sorry, Jim :(

An example project is available in the OmniThreadLibrary repository in folder examples/report generator. This post describes the inner workings of that project.

Monday, October 22, 2012

Multiple Attributes on One Line

Apparently Delphi (at least XE2, didn’t test with others) allows you to write a comma-separated attribute list inside square brackets when annotating types and type members.

IOW, following two code fragments are identical.

[Name(CNameModule2Sub1)]
[Description('Submodule 2.1)]
TModule2Sub1Info = class
end;
[Name(CNameModule2Sub1), Description('Submodule 2.1')]
TModule2Sub1Info = class
end;

I am not able to find if this is a documented behavior.

Tuesday, October 16, 2012

ITDevCon 2012 is almost here …

.. and I’m busy preparing my presentations. Come join me in Verona and listen to following talks:

Regular expressions - friend or foe?

Regular expressions are one of the most underused features of the Delphi RTL. While in the past we could attribute this to the lack of built-in support, Delphi XE introduced the RegularExpressions unit which greatly simplifies the use of the regular expressions engine. This session will present basic ideas behind the regular expressions, examine the RegularExpressions unit and in particular the main workhorse - the TRegEx class - and continue with practical examples which will show how and when to use regular expressions - and particularly when to stay away from them.

"Hands On": Parallel programming with OmniThreadLibrary

In the past few years, OmniThreadLibrary has become "de facto" standard for Delphi multithreaded programming. Still, the main stumbling block for programmers to "go multithreaded" is the grasp of patterns and practices for multithreaded development. This "hands on" session will take different practical examples, deconstruct them into basic operations and then show how to build simple parallel solutions based on the initial analysis.

"Hands-On": Developing for Windows and OS X

Multiplatform development is slowly taking hold in the Delphi world. While we can argue that the tools for the mobile platform are still in the infancy stage, the situation on the desktop is quite different. Delphi is a valid development tool for the OS X-based computers. The main topic of this session will be hassle-free multiplaftorm development - how to write your code that it "simply works" on both platforms and what to do when this is not possible.

(That is, if you’ll not be listening to other great presentations running at the same time!)

Friday, October 12, 2012

Programación Paralela con OmniThreadLibrary

Bookpage?1350027408The OTL book is now available in Spanish language!
Big thanks to jachguate who translated the book.

Finalmente, ¡aquí está la primera entrega del libro!.
  • Actualizada a la versión en Inglés publicada el 8 de octubre de 2012.
  • Adaptado a la versión 3.02 de OTL.
Contiene el contenido completo de los capítulos:
2. Introducción a MultiThreadLibrary
3. Multi-hilos de alto nivel
7. How-to
Al comprar el libro, recibirás todas las actualizaciones futuras completamente gratis.

Gracias por el interés mostrado en adquirir el libro.

Sinceramente.
Juan Antonio Castillo y Primož Gabrijelčič

Monday, October 08, 2012

OTL Book Update

A minor update of the “OmniThreadLibrary Book” has been released.
Changes:
  • Adapted to the OmniThreadLibrary 3.02 release.
    • Documented background worker initializers and finalizers.
    • Documented Async/Await abstraction.
  • Fixed minor problems found by [jachguate].
Update [2012-10-09]: Russian translation has also been updated.
Update [2012-10-12]: Spanish translation has been released.

Rarely Seen in the Wild

I don’t believe many of you had opportunity to observe this error before.

image

Wednesday, October 03, 2012

Programación Paralela con OmniThreadLibrary

otl_esIt’s official – Parallel Programming with OmniThreadLibrary is being translated into Spanish!

The translator, Embarcadero MVP Juan Antonio Castillo Hernández a.k.a. jachguate, is already working on the book. I hope we’ll have first (partial) translation ready soon.

Until then you can express the interest in the book on the LeanPub site.

OmniThreadLibrary 3.02 released

OmniThreadLibrary 3.02 was released today. This is mostly a bugfix release with few new parts (XE3 support, Async/Await). Update is strongly recommended for everybody.
Get it as a zip or from the svn.

Monday, October 01, 2012

Smart RTL

I have just published an update (63 new pages!) to A Smart Book. New topics cover important parts of the RTL libraries – graphics (HTML5 canvas), regular expressions, browser storage, accelerometer, touch and gesture, layout manager and networking (HttpRequest and JSONP). Also added was a new section on running code on application shutdown (in the Programming with Smart chapter).

Click here for more information about the book …

Wednesday, September 26, 2012

The OTL Book has 100 readers!

image

Thanks to everybody who bought the book! Your contribution to the OmniThreadLibrary project is much appreciated!

And not forget the Russian book owners. There are only 17 of them at the moment but their contribution is appreciated nonetheless. (And, again, thanks to Alex Egorov who is translating the book into Russian.)

Tuesday, September 25, 2012

OmniThreadLibrary and XE3

Just a quick notice – SVN HEAD works fine with XE3. I’m cleaning up some old issues and will be releasing new version over the weekend (most probably).

Sunday, September 23, 2012

XE3: Internal Error G9413

Today I wanted to check whether the OmniThreadLibrary plays nice with XE3 (yes, I know, I’ve should have done this weeks ago, but there was simply not enough time) and I was completely surprised when OtlSync unit couldn’t be compiled due to an internal error G9413.

One hour later I have reduced the problem to a simple test case (below) and to a simple fix. So the OmniThreadLibrary will be supported in the XE3 (as we all hoped for).

For other poor souls that may have run into this problem, here’s a small test case and a workaround.

implementation

uses
RTTI;

type
TTest<T> = class
procedure Test;
end;

var
a: IInterface;

procedure TTest<T>.Test;
var
aMethCreate: TRttiMethod;
begin
if Length(aMethCreate.GetParameters) = 0 then
;

end;

initialization
a := nil; // F2084 Internal Error: G9413
end.

The problem here is that the G9413 internal error is not reported on the line which causes the problem. The real culprit here is the ‘if Length(aMethCreate.GetParameters)’ call in the ‘TTest<T>.Test’ method.

To fix the problem it is enough to introduce a temporary variable that stores the result of the GetParameters call.

unit Unit136;

interface

implementation

uses
RTTI;

type
TTest<T> = class
procedure Test;
end;

var
a: IInterface;

procedure TTest<T>.Test;
var
aMethCreate: TRttiMethod;
params : TArray<TRttiParameter>;
begin
params := aMethCreate.GetParameters;
if Length(params) = 0 then
;
end;

initialization
a := nil;
end.

The problem is reported as QC #108942.

Tuesday, September 18, 2012

XE3 World Tour in Ljubljana

P1100946

100+ people arrived. Presentation went through without big glitches and audience was very helpful when I managed to mess things up. Thanks, folks!

Friday, September 14, 2012

Don’t Miss XE3 Event in Ljubljana!

Only four days are left until the XE3 event in Ljubljana! I’ll be showing all that is new in RAD Studio XE3 including (but not limited to) FireMonkey2, Visual LiveBindings, Windows 8 development and HTML5 Builder.

Follow this link for registration and to see the detailed timetable.

A special notice for all friends – reserve some time for a beer or two after the presentation ;)

Wednesday, September 12, 2012

Parallel Programming with OTL [RU] Update

The always hard-working Alex has translated all the new material from the OTL book so now the Russian and English version are again in sync.

Thanks for all the work, Alex!

Thursday, August 23, 2012

Parallel Programming with OmniThreadLibrary–How-tos

Good news for all OmniThreadLibrary fans – the long-awaited How-to chapter has been published.

Following topics are covered:

  • Background File Scanning
    Scanning folders and files in a background thread.
  • Async/Await
    How to write 'blocking' multithreaded code with a mechanism similar to .NET's `async`/`await`.
  • Web Download and Database Storage
    Multiple workers downloading data and storing it in a single database.
  • Parallel For with Synchronized Output
    Redirecting output from a parallel for loop into a structure that doesn't support multithreaded access.
  • Background Worker and List Partitioning
    Writing server-like background processing.
  • Parallel Data Production
    Multiple workers generating data and writing it into a single file.
  • Building a Connection Pool
    Using OmniThreadLibrary to create a pool of database connections.
  • QuickSort and Parallel Max
    How to sort an array and how to process an array using multiple threads.
  • Parallel Search in a Tree
    Finding data in a tree.
  • Multiple Workers with Multiple Frames
    Graphical user interface containing multiple frames where each frame is working as a frontend for a background task.
  • OmniThreadLibrary and Databases
    Using databases from OmniThreadLibrary.
  • OmniThreadLibrary and COM/OLE
    Using COM/OLE from OmniThreadLibrary.

Other changes and additions:

  • Added Release Notes section.
  • Fixed image sizes and line breaks in the High-level Multithreading chapter.

I will now spend few weeks finishing the Smart RTL chapter of the A Smart Book and then I’ll return to the Parallel Programming with OmniThreadLibrary. In the meantime you can express your interest in missing chapters in the poll on the right side of this blog.

Tuesday, August 21, 2012

XE3 in Ljubljana

The Ljubljana stop of the XE3 World Tour will occur on September 18th.

Register here (not yet linked from the World Tour page).

This year I’ll be doing the presentation. I’m already looking forward to that!