comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Properties
Date: Thu, 2 Dec 2010 11:26:32 +0100
Date: 2010-12-02T11:26:32+01:00	[thread overview]
Message-ID: <1sp30ekj4pmer$.1753nbz1zyzid$.dlg@40tude.net> (raw)
In-Reply-To: 18768dde-5817-40b9-aaa1-03c620ad7187@i32g2000pri.googlegroups.com

On Thu, 2 Dec 2010 01:57:49 -0800 (PST), Maciej Sobczak wrote:

> On Dec 1, 10:45�pm, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> wrote:
> 
>>> And how is this any different from, say, printing exactly the same log
>>> messages on standard output?
>>
>> It is just same. You can safely call Put_Line from any task.
> 
> Wrong (AARM Annex A, 3.a):
> 
> "simultaneous calls to Text_IO.Put will work properly, so long as they
> are going to two different files. On the other hand, simultaneous
> output to the same file constitutes erroneous use of shared
> variables."

OK, I let us consider only "reasonable" implementations of Put.

>> But if you do
>> Set_Text in GTK, that will crash your program.
> 
> You mean - that will lead to erroneous execution? So it is exactly the
> same as with printing on standard output.

I don't know if there is an Ada implementation working this way.

> Why do you expect to get better guarantees from GUI than from stdout?

Because in all Ada compilers I used so far this was safe.

>>> How do you solve this problem with Ada.Text_IO? Why the same solution
>>> cannot apply to GUI?
>>
>> I would like to have a similar solution, i.e. GUI things working without
>> switching the contexts.
> 
> "Switching the contexts" is a technical term that relates to some
> platform implementation details. I don't see why this is relevant to
> GUIs, certainly not for performance reasons.

A "reasonable" implementation of Text_IO queues I/O requests to some
internal or external task/driver. I want same sort of design for graphical
requests.

>> On the context of the main GTK task you just call Set_Text. From an alien
>> task you need to instantiate a generic, or pass a closure, or override a
>> primitive operation of a query object and from the callback call to
>> Set_Text. The router calls the callback on the context of the main task.
>> You would not do this for each graphic operations. Instead you have a sort
>> of transactions, sets of operations executed in a group. This makes the
>> code look very different. As I said it is obtrusive.
> 
> Is this a GUI problem or a general language problem?

It is a problem of the GTK library design.

> And is this really a proper design?

No.
 
> With this experience in mind, if you insist on GUI to be task-safe, I
> think it is because you want the GUI library to support poor design
> practices.

No, single thread GUI is bad design practice, that is when you block the
GUI when your dialog has a progress bar. A good design practice is that the
application does nothing functional on the context of the message loop. Any
action on this context must be a subject of design rules similar to ones
for the protected actions: non-blocking, atomic, short, semantically
instant.

> Having arbitrary application tasks calling Set_Text
> directly on some widget sounds like spaghetti.

On the contrary, spaghetti is poor man's multitasking implemented by
callbacks from timer messages on the context of the messages loop.

GUI is natively multitasking:

1. actions invoked by its controls are not instant: progress bar
2. some controls are active objects: animation widgets, visual effects,
tooltips, hovering etc
3. indication of asynchronous events and data: oscilloscope

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



  reply	other threads:[~2010-12-02 10:26 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-28  3:21 Properties Shark8
2010-11-28  8:15 ` Properties Dmitry A. Kazakov
2010-11-28 19:43   ` Properties Shark8
2010-11-29  8:34     ` Properties Dmitry A. Kazakov
2010-12-01 18:15       ` Properties Shark8
2010-11-28 12:37 ` Properties Georg Bauhaus
2010-11-28 21:22   ` Properties Shark8
2010-11-29 16:54     ` Properties Georg Bauhaus
2010-12-01 19:52   ` Properties Martin Krischik
2010-12-01 23:24     ` Properties Georg Bauhaus
2010-12-05 16:15       ` (placepo) Properties Martin Krischik
2010-12-06 23:24         ` Shark8
2010-12-01 23:31     ` Properties Georg Bauhaus
2010-11-30  1:49 ` Properties Randy Brukardt
2010-11-30 16:58   ` Properties Charmed Snark
2010-11-30 17:22     ` Properties Dmitry A. Kazakov
2010-11-30 20:27       ` Properties Warren
2010-12-01  8:39         ` Properties Dmitry A. Kazakov
2010-12-01 15:21           ` Properties Warren
2010-12-01 15:59             ` Properties Dmitry A. Kazakov
2010-12-01 16:20               ` Properties Warren
2010-12-01 18:22                 ` Properties Dmitry A. Kazakov
2010-12-01 19:36                   ` Properties Shark8
2010-12-01 21:13                     ` Properties Dmitry A. Kazakov
2010-12-01 21:35                   ` Properties Maciej Sobczak
2010-12-01 21:45                     ` Properties Dmitry A. Kazakov
2010-12-02  9:57                       ` Properties Maciej Sobczak
2010-12-02 10:26                         ` Dmitry A. Kazakov [this message]
2010-12-02 15:25                           ` Properties Maciej Sobczak
2010-12-02 15:46                             ` Properties Dmitry A. Kazakov
2010-12-02 21:11                               ` Properties Maciej Sobczak
2010-12-02 22:19                                 ` Properties Dmitry A. Kazakov
2010-12-03  4:43                                 ` Properties Randy Brukardt
2010-12-03 13:53                                   ` Properties Maciej Sobczak
2010-12-03 21:32                                     ` Properties Randy Brukardt
2010-12-04 22:13                                       ` Properties Maciej Sobczak
2010-12-06 23:30                                         ` Properties Shark8
2010-12-06 23:33                                         ` Properties Randy Brukardt
2010-12-04 17:43                           ` Properties Simon Wright
2010-12-04 20:48                             ` Properties Dmitry A. Kazakov
2010-12-04 22:27                               ` Properties Simon Wright
2010-12-04 22:31                                 ` Properties Vinzent Hoefler
2010-12-03  4:24                         ` Properties Randy Brukardt
2010-12-03  5:00                         ` Properties Shark8
2010-12-03 21:10                           ` Properties Randy Brukardt
2010-12-03 23:34                           ` Properties Jeffrey Carter
2010-12-06  6:02                             ` Properties Brad Moore
2010-12-06 23:25                               ` Properties Shark8
2010-12-01 19:48                 ` Properties Randy Brukardt
2010-12-01 21:10                   ` Properties Warren
2010-12-02  0:03                     ` Properties Shark8
2010-12-02 16:45                       ` Properties Warren
2010-12-02 17:32                         ` Properties Dmitry A. Kazakov
2010-12-02 20:45                           ` Properties Warren
2010-12-02 21:17                             ` Properties Adam Beneschan
2010-12-02 21:40                               ` Properties Warren
2010-12-03  3:34                             ` Properties Shark8
2010-12-03  8:16                               ` Properties Thomas Løcke
2010-12-02 20:52                           ` Properties Pascal Obry
2010-12-02 19:46                         ` Properties Adam Beneschan
2010-12-02 20:38                           ` Properties Warren
2010-12-02 21:39                             ` Properties Jeffrey Carter
2010-12-02 21:55                               ` Properties Warren
2010-12-03  9:33                               ` Properties Anonymous
2010-12-03  3:47                           ` Properties Shark8
2010-12-03  0:09                         ` Properties Robert A Duff
2010-12-03 15:49                           ` Properties Warren
2010-12-03 20:07                             ` Properties Shark8
2010-12-06 21:01                               ` Properties Warren
2010-12-06 23:22                                 ` Properties Shark8
2010-12-07 14:37                                   ` Properties Warren
2010-12-08 21:13                                   ` Properties Simon Wright
2010-12-09  1:21                                     ` Properties Shark8
2010-12-06 23:43                                 ` Properties Randy Brukardt
2010-12-07  0:56                                   ` Properties Jeffrey Carter
2010-12-07 11:23                                   ` Properties Maciej Sobczak
2010-12-07 11:51                                     ` Properties Georg Bauhaus
2010-12-07 15:35                                       ` Properties Maciej Sobczak
2010-12-07 17:02                                         ` Properties Georg Bauhaus
2010-12-07 14:39                                   ` Properties Warren
2010-12-03 15:40                         ` Properties Warren
2010-12-03 19:56                           ` Properties Shark8
2010-12-03 20:12                             ` Properties Warren
2010-12-03  5:53               ` Properties Shark8
2010-12-03  9:05                 ` Properties Dmitry A. Kazakov
2010-12-03 19:52                   ` Properties Shark8
2010-12-03 21:14                     ` Properties Randy Brukardt
2010-12-04  5:35                       ` Properties Shark8
2010-12-04 14:23                         ` Properties Peter C. Chapin
2010-12-04 18:53                           ` Properties Shark8
2010-12-13 15:10                       ` Properties Brian Drummond
2010-12-03 22:38                     ` Properties Dmitry A. Kazakov
2010-12-04  3:12                       ` Properties Shark8
2010-12-04 13:19                     ` Properties Georg Bauhaus
  -- strict thread matches above, loose matches on Subject: below --
2010-12-04 19:53 Properties Shark8
2010-12-04 23:27 ` Properties Thomas Løcke
replies disabled

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