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.
Thursday, February 28, 2013
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
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!
Saturday, January 26, 2013
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*
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.
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.
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
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!