Tuesday, October 30, 2012

Embarcadero Academy 2012: FireMonkey 2

Next week we (Embarcadero + Marand + me) are starting the next cycle of Delphi workshops. This time I’ll be talking about FireMonkey2 – about everything that is new & great in the latest release of this framework.
Predavanje bo – tako kot doslej – v slovenskem jeziku. Več podatkov dobite tu.
image

Monday, October 29, 2012

Welcome New OTL Committer!

Christian W. Budde has kindly offered to do a long-neglected housekeeping on the OmniThreadLibrary SVN tree. He now has committing rights and is already busy fixing .dproj files, SVN external references and other small things that I never have time to work upon.

The current state of the SVN tree may be as of this moment described as a ‘slightly unstable’ so checkout/update at your own risk. I’ll let you know when the rearrangements will have finished.

Sunday, October 28, 2012

Automagically Creating Object Fields with RTTI

While working on an internal project I came into a situation where a user (that is, a fellow programmer) would have to create a hierarchy of classes. As it turned out, this hierarchy would contain almost no implementation, just the class declarations, with one exceptions – every class would still have to be responsible for creating its children objects. Then I had a thought. Maybe I could use attributes and RTTI to do that in one central place instead of in every object.

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 …