comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Tasking and wxWidgets
Date: Sun, 27 Nov 2005 12:15:25 +0100
Date: 2005-11-27T12:15:29+01:00	[thread overview]
Message-ID: <1klj2l99vjffc.20si9rutfd0p.dlg@40tude.net> (raw)
In-Reply-To: 1133019723.900827.144340@o13g2000cwo.googlegroups.com

On 26 Nov 2005 09:26:17 -0800, Lucretia wrote:

> Dmitry A. Kazakov wrote:
>> On 25 Nov 2005 02:05:11 -0800, Lucretia wrote:
>>
>> Yes both is the case for HMIs (human-machine interface) used to control
>> some large test system (like a dynamometer.) But it is only one side of the
>> issue. Another is the actions invoked by the GUI. If an action is
>> synchronous (that's you cannot continue), and it is often the case, then
>> with a single-thread design you block the whole GUI. Now, imagine, the
>> operator starts daily log print, which is busy opening that idiotic printer
>> properties dialog. Suddenly something gets wrong, really wrong ... and the
>> "emergency stop" button is dead.
> 
> Hmm, but if each wxAda type had it's own mutex, surely you'd only end
> up locking that particular object at any one time?

Depends on what is the object here, and what is allowed to do with a mutex
taken. If there is a possibility to perform blocking actions within other
actions, then be ready for hell. One way to get out of this is to remove
mutexes from objects and pass them as parameters or discriminants. Another
is to use monitor tasks.

>> In the GUI system we developed for HMIs, rendering and data feeding are
>> often separated. They have independent cycles and consequently are used
>> from different threads. Locking overhead was never a problem [well, I
>> presume, you aren't going to perform pixelwise image transformation.] We
> 
> It's a possibility if somebody wanted to create an image manipulation
> program with wxAda?!

Do you ask me? (:-)) Look at absolutely useless Window's SetPixel. Then
you'll need double buffering and all that stuff. 

>> often use a specialized "mutex" which allows parallel read access if there
>> is no any write access. It would be nice to use Ada's protected objects
>> here, because they basically have this functionality, but unfortunately 1)
>> the thing is in C++, 2) Ada's protected objects aren't OO composable, they
>> are not tagged.
> 
> Exactly, and getting multiple objects using protected objects is
> impossible, unfortunately.

Hmm, do you mean multiple protected actions here?

>> You should also consider Ada tasks, which sometimes are more natural than
>> protected objects.
> 
> Still would be impossible to do, this is why I was considering leaving
> the library as non-thread-safe and allowing the application developer
> to handle concurrency issues.

You should separate it into safe and unsafe parts. You don't need
thread-safe String, you probably need safe Show_Text.

>> And more than two mutexes is a problem. You should try to make the API
>> composable without or minimal deadlock danger. For example, Windows GUI API
> 
> I'm not sure what you mean about "composable without or minimal
> deadlock danger"

From the messages loop [in a deeply nested callback subprogram] you spin
for a mutex held by another thread that does SetWindowText to the window.
Here you are.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2005-11-27 11:15 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-25 10:05 Tasking and wxWidgets Lucretia
2005-11-25 10:53 ` Martin Dowie
2005-11-26 17:32   ` Lucretia
2005-11-26 18:23     ` Martin Dowie
2005-11-29  3:07       ` Randy Brukardt
2005-11-29  9:13         ` Martin Dowie
2005-11-29 21:46           ` Randy Brukardt
2005-11-29 22:46             ` Martin Dowie
2005-11-25 11:37 ` Dmitry A. Kazakov
2005-11-26 17:26   ` Lucretia
2005-11-27 11:15     ` Dmitry A. Kazakov [this message]
2005-11-28 10:48       ` Lucretia
2005-11-28 14:41         ` Dmitry A. Kazakov
2005-11-26 17:26   ` Lucretia
2005-11-26 17:28   ` Lucretia
2005-11-26 17:34   ` Lucretia
2005-11-26  7:46 ` Simon Wright
2005-11-28 10:37   ` Lucretia
2005-11-29 21:38     ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox