Wednesday, September 18, 2013

XE5 Is Well Accepted

This picture was taken today in Ljubljana before the XE5 presentation (which, thank you for asking, went quite fine, with only two glitches of which one was a human – that is, mine – error).

About 65 people attended, which is a great improvement from the XE4 launch, and quite a few of them have expressed an interest in buying the Delphi/Android combo.

01_

The all present subtext was, however, that “Embarcadero should now slow down the development and FIX THE BUGS!” I cannot disagree with that – since the XE2, the Delphi has become increasingly less and less reliably. The time has come for a big spring cleanup.

Wednesday, September 11, 2013

XE5 and USB Drivers

If your XE5 installation doesn’t want to recognize attached Android phone when Windows see it perfectly well (and you have done all the groundwork including putting the phone into USB Debugging mode), check if you have installed USB drivers that support adb – the android debugger. Typically, the drivers that are installed automatically by Windows won’t work with the adb.

This page links to correct drivers for various phone manufacturers.

This StackOverflow topic may help you in case of hard-to-resolve problems.

And, of course, read the official documentation on debugging on Android devices first!

Friday, September 06, 2013

The Delphi Language is Lagging Behind

While I love the way Delphi is expanding to multiple platforms (but please, guys, stop the horses once in a while and fix some bugs!), I think the Delphi language could use a facelift. In particular, I like what Eric is doing with the DWS and I absolutely enjoy coding in Smart Mobile Studio where I could use the full power of Eric’s improvements to the language.

I absolutely love DWS’ lambda statement. Delphi’s approach to anonymous methods is so damn long-winded (even for us Pascal programmers who love to type) that lots of programmers reject it just because of the unwieldy syntax. In DWS, however, I can use

var repeater := TW3EventRepeater.Create(lambda (Sender) => MyFunction, 5000);

or

ResizeChildren(FClientArea.Height, [TAlign.Top, TAlign.Bottom],
lambda (layout) => layout.GetConfig.GetHeight,
lambda (layout, value) layout.GetConfig.Height(value) end);

Much shorter. More readable.


Also useful are properties with anonymous storage. If my property only exposes a field and doesn’t use getter or setter, I can shorten the code by 50% by not defining the field at all. Instead of

type
TMyClass = class
private
FData: integer;
public
property Data: integer read FData write FData;
end;

I can write

type
TMyClass = class
public
property Data: integer;
end;

Another nice feature are property expressions – a way to write anonymous getters and setters.

type
TToDoListTemplate=class(TW3form)
public
property Task: string read (W3lblTask.Caption) write (W3lblTask.Caption);
property Detail: string read (W3lblDet.Caption) write (W3lblDet.Caption);
end;

These are incredible time saver. If I redo this the Delphi way, I end up with a much longer code.

type
TToDoListTemplate=class(TW3form)
private
function GetDetail: string;
function GetTask: string;
procedure SetDetail(value: string);
procedure SetTask(value: string);
public
property Task: string read GetTask write SetTask;
property Detail: string read GetDetail write SetDetail;
end;






function TToDoListTemplate.GetDetail: string;
begin
Result := W3lblDet.Caption;
end;


function TToDoListTemplate.GetTask: string;
begin
Result := W3lblTask.Caption;
end;


procedure TToDoListTemplate.SetDetail(value: string);
begin
W3lblDet.Caption := value;
end;


procedure TToDoListTemplate.SetTask(value: string);
begin
W3lblTask.Caption := value;
end;

I also love type inference and in-line variable declaration which allow me to write code like this:


var item := ActionList.Items[ActionList.Add] as TLBItem;
item.Header := header;
item.Text := text;


or


for var item in ActionList.Items do


When I have to write a multiline string constant, multiline strings come handy.


writeln("Hello
World");


Even better – DWS will ignore leading common indentation if string is introduced with #” (or #’).


writeln(#"
    Hello
    World");


And last (but definitely not least), DWS implements a true conditional operator.


s := if a = 0 then 0 else 1/a;

Thursday, September 05, 2013

Delphi XE5 – Slovenian Launch

I’ll be presenting the full XE5 development powers – developing for Windows, OS X, iOS and Android in Ljubljana, on September 18th.

Register here!

Monday, August 12, 2013

OmniThreadLibrary Documentation–Low-level Multithreading

A new chapter (59 pages) on low-level multithreading has been added to the Parallel Programming with OmniThreadLibrary book. The book now has 264 pages.

Only one large part is now missing – a chapter on various supporting data structures (TOmniValue, Environment hierarchy …) and units (OtlHooks). I will write it next, then I’ll close up with the Introduction to MultiThreading.

If you have already bought the book, you should have received an email notification with download link by now. In case it got lost, please go to http://leanpub.com, log in and go to your Dashboard where you’ll be able to download the book.

If you want to buy the book, just click here. You’ll be taken to the public page for the book where you’ll also be able to download the sample PDF, which has now two new sections – an introductory part on low-level OTL programming and a section on lock-free collections.

Thursday, July 04, 2013

High-Level Multithreading webinars–recordings

All three webinars are now available for download! For a mere $10 you’ll get a hour-long presentation of OmniThreadLibrary tools that will greatly simplify your multithreaded programming.

Part I: Introduction, Async/Await, Future, Join

Part II: Parallel Task, Background Worker, Fork/Join

Part III: For Each, Pipeline

A bundle of all three webinars is also available for mere $25: High-Level Multithreading.

To download code samples and presentations, visit the OmniThreadLibrary webinars page.

Saturday, June 29, 2013

High-Level Multithreading Part III, repeat

If you have missed the webinar on Thursday or if you couldn’t reconnect after the very unfortunate dropout, you can join the retransmission on Tuesday 2nd at 10.00 AM PDT / 19.00 CET. I’ll be going through the complete webinar for the purpose of recording so you can drop in conveniently late ;)
Registration link: https://www2.gotomeeting.com/register/535786066

Thursday, June 27, 2013

State of the Software: BAD

Internet is a fragile, fragile thing. Listeners to my webinars know that.

Last time we got disconnected because of connection problems on my side.

Today, the webinar just ended. Listeners and presenters, we all just got the message that the organizer has ended the webinar. Well, he didn’t. He even restarted it and immediately got disconnected again with the same message :(

Sadly, we will not be able to finish the webinar today. I’m very very sorry for that.

Tuesday, June 25, 2013

Webinars–Reschedule and Recording

The code and slides for the Part I of the High-Level Multithreading webinar is available now at www.omnithreadlibrary.com/webinars.htm, as is the link to the downloadable video, which is being sold on Gumroad for $10.

Part II of the webinar was rescheduled for July 3rd. It will be transmitted at 15:30 CET / 9:30 EDT / 6:30 PDT / 23:30 AEST. Register here. Even if you were registered for the interrupted webinar, you'll have to register again.

If you are not yet registered for Part III yet (this Thursday at the same hour as rescheduled Part II), you can register here. Please keep in mind that all parts are independent – even if you missed part I, parts II and III will be completely understandable.

Monday, June 24, 2013

Webinar II Fail :(

I would like to apologize to everybody participating today for the technical difficulties. We had some storms in the area earlier before and they have affected internet connections more than I expected.

After a choppy first third of the webinar I completely lost connection and dropped out and now I cannot reconnect to the GoToWebinar at all. Sorry :(

We will repeat this webinar soon. I’ll post the new date here as soon as I know it.

Thursday, June 13, 2013

Register for the OmniThreadLibrary Webinars!

Everything is set up and now you can register by clicking on the links below.

Each part will last about an hour and will start at 15:30 CET / 9:30 EDT / 6:30 PDT / 23:30 AEST.

Webinars will be available for the download. They will cost $10 each and bundles with reduced price will be available. Online webinars are free to attend.

Wednesday, June 12, 2013

DataSnap/FireDAC in Ljubljana

FireDAC/DataSnap was well visited in well accepted (and I also had a great time preparing it). Big thanks to everybody for attending!
2013-06-12 09.05.24
Materials (in Slovenian language) are available here.

Tuesday, June 11, 2013

OmniThreadLibrary Webinars

Finally I am able to announce first OmniThreadLibrary Webinars. Due to the quantity of the material we decided to split the proposed two-part High-level Multithreading with OmniThreadLibrary into three parts. They will be transmitted as follows:

  • Jun 20th: High-level multithreading, part I
    Introduction to high-level abstractions, deeper look into Async/Await, Future and Join.
  • Jun 24th: High-level multithreading, part II 
    Quick overview of high-level abstractions, deeper look into ParallelTask, BackgroundWorker and Fork/Join.
  • Jun 27th: High-level multithreading, part III
    Quick overview of high-level abstractions, deeper look into ForEach (parallel ‘for’) and Pipeline.

Each part will last about an hour and will start at 15:30 CET / 9:30 EDT / 6:30 PDT / 23:30 AEST.

Link to the registration form will appear shortly on this blog. It will also be sent to participants of the survey.

Thursday, June 06, 2013

Embarcadero Academy: DataSnap and FireDAC

Next Wednesday (12th) I’ll be talking about modern data access technologies in RAD Studio XE4.

Register here.

Wednesday, May 22, 2013

XE4 for iOS in Slovenia

I just came home from the XE4/iOS presentation in Ljubljana and if I had to summarize the participant response it would be: “A very nice product, we’ll probably buy it when the Android is supported too.”

This (and a relatively small attendance) clearly shows that iOS is just not that popular in Slovenia. Even more, most of big Delphi-using companies in Slovenia have no interest in creating fresh, modern software and are still living in the “interesting, but we don’t need it” world :(

2013-05-22 09.07.20

Thanks to everybody for coming to the presentation!

Wednesday, May 15, 2013

XE4 in Ljubljana

If you live in Slovenia and if you are programming in Delphi or C++Builder, make sure to reserve some time for the next Wednesday (22nd) for the RAD Studio XE4 presentation in Ljubljana.

Most of the presentation will focus on the iOS development with RAD Studio XE4. More details here: Marand.

Tuesday, May 07, 2013

Results of the “Webinars” Survey

For Mason (and everybody else who might be interested), here are condensed results of the OmniThreadLibrary Webinars Survey.

Sunday, May 05, 2013

OmniThreadLibrary Webinars

Results of the OmniThreadLibrary Webinars Survey are now in. 77 people cared enough to answer (thanks!) and from them the Random.org site selected the winner who will get a free copy of the Parallel Programming with OmniThreadLibrary book – Mr. Nigel Hughes. Congratulations to the winner!

Considering the results of the survey we have decided that the webinars will be free and that a copy of each webinar will be available for download for $10. First 20 downloads will also get a free copy of the OTL book, courtesy of De Novo software.

Exact dates/times for webinars will be announced later this month. Stay tuned!

Monday, April 22, 2013

Programación Paralela con OmniThreadLibrary

image

After a long wait, Programación Paralela con OmniThreadLibrary has been synchronized with the english version of the book. The book has now 209 pages and is considered to be 60% complete.

Tuesday, April 16, 2013

OmniThreadLibrary Webinars

In association with De Novo Software (www.denovosoftware.com) I am preparing a series of webinars about the multithreading and OmniThreadLibrary. Currently proposed topics are:

1. High-level multithreaded programming with the OmniThreadLibrary

This two part webinar will focus on high-level abstractions (Await, Future, ParallelTask, ForEach, Pipeline etc). In addition to the in-depth presentation of all eight high-level abstractions, the webinar will explore the blocking collection, a queue class extensively used in many high-level abstractions.

2. Low-level multithreaded programming with the OmniThreadLibrary

This webinar will focus on differences between the TThread (Delphi) and CreateTask (OmniThreadLibrary) model and will be intended for programmers that have no problems writing TThread-based code. If will firstly show what the OTL equivalents for the TThread operations are and then continue by exploring the parts of the OTL that have no TThread equivalent (such as writing background tasks without the main thread loop, communicating between the main thread and the task and so on.)

3. Using OmniThreadLibrary frameworks effectively

This webinar will focus on "backend" classes in the OTL - queues, locking primitives, TOmniValue record etc. All of these can be use in any application, single-threaded or multithreaded, TThread- or OTL-based to simplify programming and improve your productivity.

4. “Do's” and “Dont's” of multithreaded programming

This webinar will present best practices for the multithreaded programming. In addition to the abstract talk, it will contain numerous code examples to prove the point.

All of the webinars will be split into 45 minute presentation followed by the 15 minute Q&A part.

Interested?

To help me determine the best time for webinars and to assess the interest, I have put together a small survey. If you are interested in participating in a webinar or downloading it for your personal use, please fill out the survey. There are only seven questions, none of them mandatory.

All participants of the survey that will leave an email address will be entered into a draw to win a prize – a free copy of the OmniThreadLibrary book!

Thursday, April 11, 2013

ThreadSafe Lock Manager: [3] Test

After you have designed and written some code, you should always test it. This is especially important for the multithreaded code which rarely works on the first (or the second, or third) try.

Friday, April 05, 2013

ThreadSafe Lock Manager: [2] Code

After explaining the design, I’ll continue my trip into the depths of the lock manager by exploring the actual code. Let’s take a look at the public parts first.

[This code is implemented in the OtlSync unit, which is part of the OmniThreadLibrary distribution. You’ll have to fetch the OTL from the SVN to use it.]

Tuesday, April 02, 2013

ThreadSafe Lock Manager: [1] Design

Few weeks ago I ran into a problem. I needed a thread-synchronizing code that would work similarly to a critical section, but would allow me to lock “anything”. If I could limit myself to objects, I could live with TMonitor.Enter/Exit, but I specifically wanted to limit access to some string keys. [In a way, my problem was similar to a problem of locking access to specific items in a string-keyed dictionary. Details differed, though.]

I was thinking about the problem and it turned out not to be a simple one. Yes, I could solve it by introducing a string-keyed dictionary of critical sections but that would be a little bit too limiting for my taste. I had some other requirements in mind which further complicated the implementation.

TL;DR – This lock manager is implemented in the OmniThreadLibrary as IOmniLockManager<K>/TOmniLockManager<K> in the OtlSync unit since revision 1268.

Tuesday, March 26, 2013

Using Generics to Manipulate Enumerated Types

I’d like to present a short class written by my colleague at work. Why? Because I just love how it uses the generics syntax to simplify some operations on enumerated types.

Like me, he hated the hoops one must jump through to convert an instance of an enumerated type to a string, to check if an integer value that was read from some storage contains a valid integer representation of some enumerated value and to enumerate (no pun intended) over such a type. Unlike me, he did something about that and wrote a Spring-inspired Range<T>.

Monday, March 11, 2013

Numbers I Should Keep In Mind

Name Nanoseconds
L1 cache reference 0.5
Branch mispredict 5.0
L2 cache reference 7.0
Mutex lock/unlock 100.0
Main memory reference 100.0
Compress 1K bytes with Zippy 10,000.0
Send 2K bytes over 1 Gbps network 20,000.0
Read 1 MB sequentially from memory 250,000.0
Round trip within same datacenter 500,000.0
Rusty disk seek 10,000,000.0
Read 1 MB sequentially from network 10,000,000.0
Read 1 MB sequentially from disk 30,000,000.0
Send packet from CA->Netherlands->CA 150,000,000.0

From always excellent kellabyte.

Friday, March 08, 2013

Embarcadero Academy: The Power of XE3

Next Wednesday (March 13th) we have organized a presentation for all users that are afraid to upgrade and are staying (for example) with Delphi 7. In “The Power of XE3” session I’ll go through all* new features added to the Delphi and C++ Builder since Delphi 7 days. We’ll discuss language changes, platform changes, framework changes, additions to the VCL, RTL, database layer …

Register here.


* As much as humanly possible. There are simply too many to cover them all.

Wednesday, March 06, 2013

Developer Wanted

The following text is a job offer for a Slovenian developer and is therefore written in Slovenian language.

Iščemo Delphi razvijalca za izpeljavo večmesečnega projekta. Zahteve: zna (ali se je pripravljen naučiti) osnovega dela z zbirnikom. Delovno mesto je v Ljubljani. Delo na domu ni možno.

Projekt je dvodelen, prva faza vsebuje predelavo aplikacij na MS Ribbon, druga pa predelavo taistih aplikacij, da se bodo prevedle za Win64.

Ob uspešni izvedbi projekta obstaja tudi možnost zaposlitve za nedoločen čas.

Prijave (s CV) in dodatna vprašanja pošljite na sandra.support@fab-online.com, v subject pa vpišite "razpis Delphi".

Če vas zanima, s čim se ukvarjamo, si oglejte www.fab-online.com.

Thursday, February 28, 2013

When Does “Execute on Destroy” Fail

Yesterday I wrote a post about executing some code automatically when a method ends. Today I’ll show you why this approach must be used with care.

OmniThreadLibrary on Google+

OmniThreadLibrary now has its own Google+ community so you are welcome to visit it and ask questions, report bugs, discuss possible OmniThreadLibrary improvements and so on …

Wednesday, February 27, 2013

Running “Any” Code When a Method Ends

Just like (some) other programmers, I like to abuse the fact that the Delphi compiler only destroys local interfaces when a method ends. If you don’t know what I’m talking about, check out the latest Nick’s post in the Fun Code of the Week series.

As an example, Nick put together a function which changes application cursor and at the end of the method reverts it back to the previous state.

procedure test;
begin
  AutoCursor(crHourGlass);
  // some long operation
  // cursor is automatically reverted when ‘test’ exits
end;

My approach to this pattern is usually slightly different. I like to mark the scope of the local interface with a with statement.

Thursday, February 21, 2013

Accessing Input Queue of a Pipeline Stage

On the today’s “Multithreading” workshop, a request popped up – a potential OmniThreadLibrary user asked how to access an input queue of a specific pipeline stage. As this was the second time this request was presented, I decided to implement this feature. It turned out that all available information was already present and I just had to expose it.

Sunday, February 17, 2013

Embarcadero Academy: Multithreaded Programming 1.1

The “Embarcadero Academy 2012” series of Delphi-related workshops was very well accepted in Slovenia so we (Embarcadero, Slovenian distributer Marand and me) have extended it into year 2013. The first workshop will be – due to a popular demand – revisited extended workshop on multithreaded programming. I’ll be extending the topics covered in the first workshop with many practical examples.

The date is slightly awkward – February 21st, the same date when Embarcadero will present the “Delphi for iOS” programming tool. Luckily, we’ll finish around 01:00PM which will give everyone enough time to return to the office and watch the webinar which starts at 03:00PM. (We apologize for this – we selected the date when Embarcadero’s webinar was still announced for the 14th but then Emb. moved the date a week ahead.)

As always, workshop will be lead in Slovenian language. Register here!

Monday, January 28, 2013

The OTL Book–Russian Edition

Just a quick notice to my readers – the Russian translation of Parallel Programming with OmniThreadLibrary has been updated and now contains all the material from the English edition.

Big thanks go to Alex Egorov for his hard work!

image

Saturday, January 26, 2013

Žarko is back!

Add this link to your RSS reader: http://zarko-gajic.iz.hr/feed/

Monday, January 21, 2013

Sending Event Handlers Across Thread Boundary

Recently, I ran into an interesting problem. I was doing some high-bandwidth, low-latency data processing where a background task received the data, dispatched it to a central hub which then forwarded data to the appropriate data processing & transmitting thread. Data absolutely had to travel through the main thread (the reasons for that are quite convoluted and not important for the story) which bothered me from a performance viewpoint. This could introduce some unwanted overhead as I can only send data to the main thread via Windows messages.

The simplest (given the current codebase) way to solve the problem was to introduce an asynchronous event handler. The main thread implements an event handler called for each received data block and passes this event handler to the receiver thread, which calls the event handler from its own context. As a result, the code that logically belongs to the main thread is executed from the worker thread and there is (almost) no delayed introduced. (The ‘almost’ part coming from the fact that I had to use some locking to synchronize operations inside the main thread.)

During the implementation phase, I found out that it’s quite difficult to send an event handler over the OmniThreadLibrary communication channel. The solution was non-trivial and required quite some ugly hacks so I’m posting it here for future reference.

Friday, January 18, 2013

DataSnap Speed & Stability, Part 2

As the Roberto’s blog is still not listed on the DelphiFeeds, I’d like to bring your attention to his second article about DataSnap: DataSnap analysis based on Speed & Stability tests – Part 2.

Saturday, December 22, 2012

Parallel Programming with OmniThreadLibrary: Synchronization

The “OTL book” has just been extended with a chapter on synchronization (22 pages). Basic understanding of synchronization issues and critical section usage is required as this chapter only deals with OmniThreadLibrary-specific support for locking.

Tuesday, December 18, 2012

OmniThreadLibrary ile Paralel Programlama*

image

Due to a strong language barrier we don’t hear from Turkish programmers much even though the programming (and Delphi) community in this big country is quite strong. That’s why I was pleasantly surprised when I received a proposal from that country to translate the OmniThreadLibrary book. We quickly set up a workflow (as the OTL book is still being written this is not a trivial task) and the book is now being translated.

Although I didn’t see more than a few translated paragraphs yet, I have great hopes that the initial Turkish release will join the ever growing family of the OTL books (English, Russian, Spanish) early next year. Until then, you can express the interest in the book here.

Great thanks go to Tugrul Helvaci for initiating the project and to Ramazan Gülbahar for translating the book!

* Parallel Programming with OmniThreadLibrary

Friday, November 23, 2012

DataSnap Speed & Stability

As the Roberto’s blog is not yet included in the DelphiFeeds concetrator, I’d like to bring to your attention his very interesting post: DataSnap analysis based on Speed & Stability tests.

Embarcadero Academy: Live Bindings

On Thursday, 29th I’ll be leading a workshop about LiveBindings and Visual LiveBindings in Ljubljana. The workshop will cover both XE2 and XE3 and will also cover differences between the VCL and FireMonkey implementation.

Predavanje bo v slovenskem jeziku. Prijavite se tu.

image

Sunday, November 11, 2012

FireMonkey2 in Ljubljana

Last week I spoke at FireMonkey2 workshop in Ljubljana. Attendance was low (compared to other “Embarcadero Academy” sessions) but very attentive and interested in the FireMonkey development.

FireMonkey2

Next session will be dedicated to LiveBinding (visual and nonvisual – both XE2 and XE3 will be covered) and is planned for 29. November. I’ll put a notice on my blog when a registration page is up.

Wednesday, November 07, 2012

OTL Repo Stable Again

Christian has finished the housekeeping tasks (days ago but I was busy and forgot to put a notice on the blog, sorry), so the repository is stable again.

Changes, with his own words:

  • introduced lib path (now all lowercase) to receive all DCU files separated by compiler, platform and configuration. The tests compile really quick now, without "polluting" the source directory with .dcu files
  • changed fastmm4 to fastmm, which is now an svn:external
  • added main icon for all tests (linked via MainIcon.rc resource script)
    • this still might cause linking issues on Delphi 2007, if compiled for the first time, but I will investigate this in the next days.
  • removed unused files and directories from the svn repository

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 …

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!

Tuesday, July 31, 2012

Async/Await in Delphi

Let’s assume you’ve inherited this pretty useless code.
procedure TForm125.Button1Click(Sender: TObject);
var
  button: TButton;
begin
  button := Sender as TButton;
  button.Caption := 'Working ...';
  button.Enabled := false;
  Sleep(5000);
  button.Enabled := true;
  button.Caption := 'Done!';
end;

Now, your boss says, you have to make it parallel so the user can start three copies of it. (You also have to add two new buttons to the form to start those instances but that’s easy to do.)

Tuesday, July 17, 2012

Параллельное программирование с OmniThreadLibrary

Alex did the impossible and translated all existing parts of Parallel Programming with OmniThreadLibrary in a record time! The Russian version of the book is now on sale at LeanPub.

Параллельное программирование с OmniThreadLibrary

Click here for additional information about the book…

Monday, July 16, 2012

Programming with Smart

Today I have published a new chapter in A Smart Book – Programming with Smart. Inside you’ll find:

  • My First Smart Program
  • File Management
  • Application Architecture
  • Forms and Navigation
  • Message Dialogs
  • Themes and Styles
  • Command-line Applications
  • Writing Games

Click here for more information about the book …

Tuesday, July 10, 2012

Параллельное программирование с OmniThreadLibrary *

bookpage[* Translation: Parallel Programming with OmniThreadLibrary]

Fellow programmer Егоров Александр (Alex Egorov) has offered to translate the OmniThreadLibrary book into Russian.

As the original book, it will be published on the LeanPub. Current plan is to make it available after the High-level multithreading chapter is translated. At the moment, you can download the first draft which contains translated Introduction.

You can express your interest in the book here.

Sunday, July 08, 2012

Introduction to OmniThreadLibrary

The Introduction to OmniThreadLibrary chapter is completed. New version of the book has already been published and all buyers have been notified by the email.

Wiki will be updated soon.

Please remember – the best way to support the OmniThreadLibrary project is to buy the book!

The next chapter will be either Synchronisation or How-to. I’ll give you few more days of voting time to decide the matter.

Friday, July 06, 2012

New Poll

There’s a new poll available – look to the right and you’ll see it.

If you have any preferences on what you want to read in the Parallel Programming with OmniThreadLibrary next, please vote.

Thursday, July 05, 2012

High-level Multithreading

Chapter five of my book Parallel Programming with OmniThreadLibrary is now completed. New version of the book has already been published and all buyers have been notified by the email.

Wiki will be updated soon.

Please remember – the best way to support the OmniThreadLibrary project is to buy the book!

The next chapter on the list is Introduction to OmniThreadLibrary which won the public poll by a very small margin (34 votes against the 31 votes for the Synchronisation chapter).

Smart Controls

Today I have published new version of the A Smart Book.

Newly added chapter Smart Control on 54 pages covers all built-in controls, from TW3Panel to TW3Header. Additional sections include tips on writing custom controls and description of the TW3ScrollControl control.

Sample book was also extended. In addition to Smart Pascal and Regular Expressions chapters it now contains selected parts from the Smart Controls chapter, including full text on TW3EditBox and TW3Toolbar.

Click this link for more information about the book …

Wednesday, July 04, 2012

OmniThreadLibrary Documentation: Blocking Collection

A chapter on blocking collection (IOmniBlockingCollection) is now available online.

Tuesday, July 03, 2012

OmniThreadLibrary Documentation: ForkJoin

A chapter on Parallel.ForkJoin is now available online.

Better OnStop

Pop quiz! What’s wrong with this code?

  FPipeline1 := Parallel.Pipeline
.Stage(
procedure (const input: TOmniValue; var output: TOmniValue)
begin
end)
.Stage(
procedure (const input: TOmniValue; var output: TOmniValue)
begin
end)
.OnStop(
procedure
begin
Caption := 'All done';
FPipeline1 := nil;
end)
.Run;
FPipeline1.Input.CompleteAdding;