In my $$$ line of programming, everything revolves around threads. Servers, multithreaded processing on clients, real time hardware control ... you name it. In all the years I've learned many dos and don'ts of multithreaded programming. I've also written few frameworks to simplify this job and most of them are already retired. Sometimes a potentially good approach turns out not to be so good at all ...
In the last year I've become more and more unhappy with my current framework and decided that it's time for something better, something simpler. Something built from scratch. This time I didn't start with the implementation but tried to visualize how I'd like to use my framework in real-life applications. After all, I had all those test cases lying around in form of my old applications using old framework. And so, the OmniThreadLibrary was born.
Currently OTL is in a very fluent alpha state. I'm already using it in my projects but some more important interfaces are changing from day to day. Still, you're invited to try it and to comment on its usefulness. If you can give me an example of real-world problem that can't be implemented using OTL, all the better. Maybe I'll be able to enhance the OTL to suite your purpose more.
OTL is living on the Google Code hosting and is BSD licensed. Current implementation only supports Delphi 2007 (although I'd been told that only small modifications are required to make it work with Delphi 2006) and unless I'm given a very convicting business case support for older Delphis won't be included. Let's look into future, not into past.
Some examples are included in the repository, but not all parts of the current infrastructure are explored. I'll post more on OTL and describe examples and OTL's inner workings on this blog in the next few days.
Hi,
ReplyDeleteI really like your library as it is helping me understand and use threads. Just a question as I am a beginner: how can I use your library for a download manager?
If you're using ICS for TCP/IP work then you have no reasons to use threads at all.
ReplyDeleteIf you're using Indy or something else, I have no idea. I'm using ICS for all my internet needs.
I use synapse - similar to Indy.
ReplyDeletethanks for your help anyway.
ramos
If I understand Indy correctly, you have to start separate thread for each request. Is this the same with Synapse?
ReplyDeleteIn most cases you'd want to use the approach from Example #4a (or from Example 4, but as you're a beginner, you'd probably want to keep away from interfaces). I'm guessing that each download task would need a .MsgWait decorator, too.
Still, all that is just a guess - if anybody here knows the Synapse, please leave a more useful comment.
No - Synapse uses blocking sockets, there is no async or threading support (the upside being the library's elegance and simplicity), which is probably why ramos wanted to use threads.
ReplyDeleteIn that case, it's really simple.
ReplyDeleteCreate a task and send it URL to download. In the task code, download the URL with Synapse. Send a message back to the owner (Task.Comm.Send()) when URL is downloaded.
As for the pausing of downloads, cancellation and other important parts of the download manager - I have no idea as I don't know how Synapse works.
Do you happen to know what small modifications need to be made to the code for it to work in Delphi 2006?
ReplyDeleteI believe it had to do with record constructors.
ReplyDeleteStill, that was many versions ago. I have no idea if the code can be made working in Delphi 2006 at this time.
Delphi 7 is not supported because there is no reason?
ReplyDeleteHave a look at this survey:
Survey
There is no reason *for*me* to support Delphi 7. I'm not using D7 anymore and neither are my clients. The last one switched to D2007 few months ago.
ReplyDeleteIf a company somewhere out there had a strong business case to use the OTL in an older Delphi, they can outsorse the conversion project to me, of course.
If anybody else wants to modify the OTL to work with D7, I'll included modified version in the SVN. I won't actively support it, though. D7 is history, people, face it.
D7 is the last stable Delphi release, infa 100%.
ReplyDeleteNovadays I'm not going to use this platform for anything than UI-heavy applications or write-only DB wrappers. I prefer dotnet for some complicated things like async I/O, tasks, high-level multithreading which Delphi supports poorly.
Understand me correctly - I don't blame you and OTL, may be it's OK in latest Delphi versions. However for my career I haven't seen any third-party delphi library/component which can be marked as "reliable". Even standard library needs to be fixed - it really strains.
When I chose .NET for developing auxiliary modules I've started to enjoy my work. Not ads. Bye :)