comp.lang.ada
 help / color / mirror / Atom feed
From: "Dan'l Miller" <optikos@verizon.net>
Subject: Re: Ada-Oriented GUI
Date: Tue, 20 Mar 2018 19:22:37 -0700 (PDT)
Date: 2018-03-20T19:22:37-07:00	[thread overview]
Message-ID: <0a1e0664-f657-4596-9672-5440ebe4caf2@googlegroups.com> (raw)
In-Reply-To: <p8ruq0$5dt$1@franka.jacob-sparre.dk>

On Tuesday, March 20, 2018 at 4:34:59 PM UTC-5, Randy Brukardt wrote:
> I can't speak to all such systems, but the above is definitely not true of 
> Windows Win32. The GUI can be on any thread that it likes, the restriction 
> is that one needs to use a single thread to create windows and receive 
> messages.

That is actually not quite true either.  A window can be created by any thread, but henceforth for that window that thread becomes the UI thread for that window.  Another window with overlapping lifetime can be created on any thread (including the prior window's UI thread), but henceforth for this new window whichever thread it was created on becomes the UI thread fro that window.  The default is for all windows to be created on the Main thread, for which a dispatcher is provided.  Other threads must establish their own dispatcher for Windows events, as it is not already provided on non-Main threads.

This becomes more pronounced in post-Win32/WoW •frameworks•, such as UWP (nee WinRT).  The underlying OS is still Win32-based, but Win32 is increasingly unutilized in modern Microsoft programming.  Nowadays instead of Win32, we access all Microsoft operating systems via frameworks that are derived from ATL/COM technology, presented as DLLs with .WinMD supplementary mark-up that is accessible to the CLR for the CLR-based managed-runtime languages (i.e., C#, F#, Visual Basic, C++/CLI) and accessible in translation to processor-native languages (i.e., C++/CX*, C++/WinRT**).

* C++/CX is C++/CLI reworked to not compile to bytecode, but using the same grafted-on “divided by” C#-esque language to access the DLLs-with-.winMD-markup.

** C++/WinRT is ISO standard C++ that uses a code generator to move much of what C++/CX does at runtime to access the DLLs-with-.winMD-markup to build-time, so that /CLI's & /CX's grafted-on “divided by” C#-esque language is no longer necessary to access the DLLs-with-.windMD-markup.

Because Win32 is increasingly obsolescent, let's look at precisely what I was mentioning above regarding back-end processing threads submitting subroutines to execute on the window's “contract” UI thread.  Note CoreDispatcher's RunAsync family of methods that do precisely what I mentioned originally:  “Invariably, nearly all modern GUI-equipped OSes have a execute-this-subroutine/lambda-on-the-main-thread call in the GUI framework.”  To handle the UWP/WinRT era since Windows 8, I should have defined the term “each window's contract UI thread” and then said that on Android, iOS, and MacOS the contract UI thread is absolutely limited to the main thread for all windows/views, and the path of least resistance on UWP/WinRT is for the main thread to be the sole contract UI thread for all windows.

https://docs.microsoft.com/en-us/uwp/api/Windows.UI.Core.CoreDispatcher

> (Any thread can do other operations.) We took advantage of this in 
> the design of Claw, where there is a separate Ada task created solely for 
> the purpose of managing the GUI. On top of this we built a fairly 
> conventional OOP design where the GUI task dispatches to appropriate 
> subprograms. This allows Ada programs fairly free access to the GUI from any 
> task. (It also has the downside of bringing in tasking issues into any Claw 
> program, even if there aren't any explicit tasks.)
> 
> It would be easy for Jeff to build his GUI design on top of Win32,

I never said that it wouldn't be.  I was saying that rarely is a design tied to absolutely running nontrivial amounts of non-UI code on the Main thread.  Let's assume that the ID of Main thread is fixed as 0 or 1 is all OSes.  Very rarely is a design so incredibly fixated on running on the thread with that ID.  Most designs don't care that they are running code on thread whose ID is 17 instead of the initial/Main thread, as long as there exists a way to find thread 17 when absolutely necessary when executing code on non17 threads.  (But better designs would not make such demands.)  My devil's-advocate point is:  what on Earth is the big deal about this design flexibility to demand that UI processing be performed on one or more non-Main thread(s)?  If a design is fixated on this dubious axiom as a immovable-mountain requirement, then it absolutely is •never• portable to Android, iOS, and MacOS to name a few, where UI processing is absolutely limited to executing on the main thread in the modern frameworks (legacy antiques such as XQuartz and Carbon notwithstanding on Mac).

  reply	other threads:[~2018-03-21  2:22 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-18 13:33 Ada-Oriented GUI Jeffrey R. Carter
2018-03-19  2:03 ` Dan'l Miller
2018-03-19 14:10   ` Dan'l Miller
2018-03-21  9:49     ` Alejandro R. Mosteo
2018-03-21 13:58       ` Dan'l Miller
2018-03-21 18:43         ` briot.emmanuel
2018-03-21 19:17           ` Shark8
2018-03-21 22:40             ` Randy Brukardt
2018-03-21 23:52               ` Shark8
2018-03-22  6:50                 ` briot.emmanuel
2018-03-22 16:56                   ` Shark8
2018-03-23 16:29               ` Shark8
2018-03-23 22:59                 ` Randy Brukardt
2018-03-23 23:43                   ` Mehdi Saada
2018-03-26 22:09                     ` Randy Brukardt
2018-03-27  7:27                       ` Dmitry A. Kazakov
2018-03-27 23:58                         ` Randy Brukardt
2018-03-28  7:09                           ` Dmitry A. Kazakov
2018-03-22 17:34         ` Alejandro R. Mosteo
2018-03-22 17:50           ` Dan'l Miller
2018-03-22 18:58             ` Shark8
2018-03-23 12:06             ` Alejandro R. Mosteo
2018-03-20 16:41 ` Dan'l Miller
2018-03-20 21:34   ` Randy Brukardt
2018-03-21  2:22     ` Dan'l Miller [this message]
2018-03-21 21:50       ` Randy Brukardt
2018-03-22  8:45         ` Dmitry A. Kazakov
2018-03-22 10:58         ` Bojan Bozovic
2018-03-22 11:03           ` Bojan Bozovic
2018-03-21  8:25 ` Dmitry A. Kazakov
2018-03-21 14:30   ` Dan'l Miller
2018-03-21 15:57     ` vincent.diemunsch
2018-03-21 17:33       ` Dan'l Miller
2018-03-21 16:27     ` Dmitry A. Kazakov
2018-03-21 17:04       ` Dan'l Miller
2018-03-21 17:42         ` Dmitry A. Kazakov
2018-03-21 18:19           ` Dan'l Miller
2018-03-21 19:11             ` Simon Wright
2018-03-21 19:51               ` Dan'l Miller
2018-03-21 20:11                 ` Dmitry A. Kazakov
2018-03-21 20:33                   ` Dan'l Miller
2018-03-21 22:16                   ` Dan'l Miller
2018-03-22  9:12                     ` Dmitry A. Kazakov
2018-03-22 14:57                       ` Dan'l Miller
2018-03-22 15:46                         ` Bojan Bozovic
2018-03-22 14:00                     ` Dan'l Miller
2018-03-22 17:29                   ` Alejandro R. Mosteo
2018-03-21 21:58             ` Randy Brukardt
2018-03-26 21:20               ` G. B.
2018-03-21 22:33             ` Randy Brukardt
2018-03-22  1:43               ` Dan'l Miller
2018-03-22 23:47                 ` Randy Brukardt
2018-03-23  2:37                   ` Dan'l Miller
2018-03-23 22:42                     ` Randy Brukardt
2018-03-24  7:47                       ` Simon Wright
2018-03-23  9:05                   ` Jeffrey R. Carter
2018-03-23  9:48                     ` Bojan Bozovic
2018-03-23 10:20                     ` Alejandro R. Mosteo
2018-03-27 18:32                     ` Killing software and certification (was: Ada-Oriented GUI) Alejandro R. Mosteo
2018-03-27 19:25                       ` Killing software and certification Dmitry A. Kazakov
2018-03-28 13:54                         ` Alejandro R. Mosteo
2018-03-28 14:23                           ` Dmitry A. Kazakov
2018-03-28 17:06                             ` Alejandro R. Mosteo
2018-03-28 19:35                               ` Dmitry A. Kazakov
2018-03-28 15:47                           ` Jeffrey R. Carter
2018-03-28 17:02                             ` Dennis Lee Bieber
2018-03-28 17:59                             ` Dan'l Miller
2018-03-27 19:41                       ` Killing software and certification (was: Ada-Oriented GUI) Dan'l Miller
2018-03-28  0:04                         ` Randy Brukardt
2018-03-28  2:27                           ` Dan'l Miller
2018-03-28 13:54                           ` Killing software and certification Alejandro R. Mosteo
2018-03-28  0:21                       ` Killing software and certification (was: Ada-Oriented GUI) Jere
2018-03-28 13:54                         ` Killing software and certification Alejandro R. Mosteo
2018-03-23 12:31                   ` Ada-Oriented GUI Alejandro R. Mosteo
2018-03-23 12:59                     ` Dmitry A. Kazakov
2018-03-23 16:16                       ` Dan'l Miller
2018-03-23 17:18                         ` Dmitry A. Kazakov
2018-03-23 18:31                           ` Dan'l Miller
2018-03-23 20:06                             ` Dmitry A. Kazakov
2018-03-23 20:48                               ` Mehdi Saada
2018-03-23 21:18                                 ` Dmitry A. Kazakov
2018-03-24 11:36                       ` Alejandro R. Mosteo
2018-03-24 13:12                         ` Dmitry A. Kazakov
2018-03-28 14:09                           ` Alejandro R. Mosteo
2018-03-28 15:02                             ` Dmitry A. Kazakov
2018-03-28 18:07                               ` Alejandro R. Mosteo
2018-03-29  7:58                                 ` Dmitry A. Kazakov
2018-04-02 22:13                               ` Robert I. Eachus
2018-04-03  8:31                                 ` Dmitry A. Kazakov
2018-04-03 22:32                                   ` Robert I. Eachus
2018-04-04  7:30                                     ` Dmitry A. Kazakov
2018-03-25 12:57                         ` Jeffrey R. Carter
2018-03-24 16:33                   ` Dan'l Miller
2018-03-26 22:29                     ` Randy Brukardt
2018-03-27  0:15                       ` Dan'l Miller
2018-03-27  6:08                       ` Dennis Lee Bieber
2018-03-27  7:52                         ` Simon Wright
2018-03-27 14:48                           ` Dennis Lee Bieber
2018-04-01 17:37                       ` Robert I. Eachus
2018-03-25 19:19 ` Andrew Shvets
  -- strict thread matches above, loose matches on Subject: below --
2018-03-23 22:48 Randy Brukardt
2018-03-24  7:51 ` 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