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=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.18.138 with SMTP id 10mr8836826ios.70.1521598958198; Tue, 20 Mar 2018 19:22:38 -0700 (PDT) X-Received: by 2002:a9d:29d2:: with SMTP id g18-v6mr1143731otd.5.1521598957795; Tue, 20 Mar 2018 19:22:37 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!u184-v6no881517ita.0!news-out.google.com!j10-v6ni471ite.0!nntp.google.com!199-v6no1320775itl.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 20 Mar 2018 19:22:37 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=47.185.233.194; posting-account=zwxLlwoAAAChLBU7oraRzNDnqQYkYbpo NNTP-Posting-Host: 47.185.233.194 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <0a1e0664-f657-4596-9672-5440ebe4caf2@googlegroups.com> Subject: Re: Ada-Oriented GUI From: "Dan'l Miller" Injection-Date: Wed, 21 Mar 2018 02:22:38 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:51088 Date: 2018-03-20T19:22:37-07:00 List-Id: 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 o= f=20 > Windows Win32. The GUI can be on any thread that it likes, the restrictio= n=20 > is that one needs to use a single thread to create windows and receive=20 > messages. That is actually not quite true either. A window can be created by any thr= ead, but henceforth for that window that thread becomes the UI thread for t= hat window. Another window with overlapping lifetime can be created on any= thread (including the prior window's UI thread), but henceforth for this n= ew 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 t= hreads. This becomes more pronounced in post-Win32/WoW =E2=80=A2frameworks=E2=80=A2= , such as UWP (nee WinRT). The underlying OS is still Win32-based, but Win= 32 is increasingly unutilized in modern Microsoft programming. Nowadays in= stead of Win32, we access all Microsoft operating systems via frameworks th= at are derived from ATL/COM technology, presented as DLLs with .WinMD suppl= ementary mark-up that is accessible to the CLR for the CLR-based managed-ru= ntime languages (i.e., C#, F#, Visual Basic, C++/CLI) and accessible in tra= nslation 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 =E2=80=9Cdivided by=E2=80=9D C#-esque language to access the DL= Ls-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 =E2=80=9Cdivided by=E2=80=9D C#-es= que language is no longer necessary to access the DLLs-with-.windMD-markup. Because Win32 is increasingly obsolescent, let's look at precisely what I w= as mentioning above regarding back-end processing threads submitting subrou= tines to execute on the window's =E2=80=9Ccontract=E2=80=9D UI thread. Not= e CoreDispatcher's RunAsync family of methods that do precisely what I ment= ioned originally: =E2=80=9CInvariably, nearly all modern GUI-equipped OSes= have a execute-this-subroutine/lambda-on-the-main-thread call in the GUI f= ramework.=E2=80=9D To handle the UWP/WinRT era since Windows 8, I should h= ave defined the term =E2=80=9Ceach window's contract UI thread=E2=80=9D and= then said that on Android, iOS, and MacOS the contract UI thread is absolu= tely limited to the main thread for all windows/views, and the path of leas= t 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=20 > the design of Claw, where there is a separate Ada task created solely for= =20 > the purpose of managing the GUI. On top of this we built a fairly=20 > conventional OOP design where the GUI task dispatches to appropriate=20 > subprograms. This allows Ada programs fairly free access to the GUI from = any=20 > task. (It also has the downside of bringing in tasking issues into any Cl= aw=20 > program, even if there aren't any explicit tasks.) >=20 > 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 tie= d to absolutely running nontrivial amounts of non-UI code on the Main threa= d. 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 wi= th that ID. Most designs don't care that they are running code on thread w= hose 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 non= 17 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 flexibi= lity to demand that UI processing be performed on one or more non-Main thre= ad(s)? If a design is fixated on this dubious axiom as a immovable-mountai= n requirement, then it absolutely is =E2=80=A2never=E2=80=A2 portable to An= droid, iOS, and MacOS to name a few, where UI processing is absolutely limi= ted to executing on the main thread in the modern frameworks (legacy antiqu= es such as XQuartz and Carbon notwithstanding on Mac).