From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,36a29c2860aff686 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news3.google.com!feeder.news-service.com!news2.euro.net!newsfeed.freenet.ag!news.netcologne.de!ramfeed1.netcologne.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Properties Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <3b84c8e7-1a51-4a7c-9646-119f1fc51478@s4g2000yql.googlegroups.com> <4pnv7nl4cdui$.1n28i7lqk4mek$.dlg@40tude.net> <1k7367gtebsgm$.18auo6u3nfg34.dlg@40tude.net> <1u5dftkqqi68c.10079qnqyyfwb$.dlg@40tude.net> <15tv4yga36dpi$.1hc09dlbgcmqe.dlg@40tude.net> <18768dde-5817-40b9-aaa1-03c620ad7187@i32g2000pri.googlegroups.com> Date: Thu, 2 Dec 2010 11:26:32 +0100 Message-ID: <1sp30ekj4pmer$.1753nbz1zyzid$.dlg@40tude.net> NNTP-Posting-Date: 02 Dec 2010 11:26:32 CET NNTP-Posting-Host: b6f67b1b.newsspool1.arcor-online.net X-Trace: DXC=W?PQ0a76l04kUFX=Y?aLP;ic==]BZ:af>4Fo<]lROoR1<`=YMgDjhg2E>BTRb^`4f;[6LHn;2LCV>7enW;^6ZC`4\`mfM[68DC34KQUZWClYg3 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:16713 Date: 2010-12-02T11:26:32+01:00 List-Id: On Thu, 2 Dec 2010 01:57:49 -0800 (PST), Maciej Sobczak wrote: > On Dec 1, 10:45�pm, "Dmitry A. Kazakov" > 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