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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.13.230.150 with SMTP id p144mr4451647ywe.46.1467146675936; Tue, 28 Jun 2016 13:44:35 -0700 (PDT) X-Received: by 10.157.47.177 with SMTP id r46mr304952otb.15.1467146675892; Tue, 28 Jun 2016 13:44:35 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!jk6no5684897igb.0!news-out.google.com!o189ni8292ith.0!nntp.google.com!r1no5705296ige.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 28 Jun 2016 13:44:35 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=149.32.224.36; posting-account=Qh2kiQoAAADpCLlhT_KTYoGO8dU3n4I6 NNTP-Posting-Host: 149.32.224.36 References: <58b78af5-28d8-4029-8804-598b2b63013c@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <324a8516-b728-4775-854f-fbf411fa7647@googlegroups.com> Subject: Re: RFC: Prototype for a user threading library in Ada From: Anh Vo Injection-Date: Tue, 28 Jun 2016 20:44:35 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:30963 Date: 2016-06-28T13:44:35-07:00 List-Id: On Saturday, June 25, 2016 at 11:15:48 PM UTC-7, Dmitry A. Kazakov wrote: > On 2016-06-26 05:21, Randy Brukardt wrote: > > "Dmitry A. Kazakov" wrote in message > > news:nkl8bm$19q7$1@gioia.aioe.org... > >> On 2016-06-24 02:38, rieachus@comcast.net wrote: > >>> I don't get it. If this is your "motivation": > >>> > >>>> The motivation is a two-liner. Let you have some consumer of data: > >>>> > >>>> procedure Write (Buffer : String; Last : out Integer); > >>>> > >>>> It may take less than the whole string when called, but will take mo= re > >>>> data later. So, the parameter Last. Now you want to write a program = in a > >>>> *normal* way: > >>>> > >>>> Write ("This"); > >>>> Write ("That"); > >>>> > >>>> That's it. > >>> > >>> You may want to make your Last parameter in or in out, but that's a > >>> detail. > >> > >> It is not a detail. The caller of Write does not know how much data th= e > >> transport layer is ready to accept. That is the nature of non-blocking > >> I/O. Write takes as much data it can and tells through Last where the > >> caller must continue *later*. > >> > >> A blocking busy-waiting wrapper looks this way: > >> > >> procedure Write (Buffer : String) is > >> First : Integer :=3D Buffer'First; > >> Last : Integer; > >> begin > >> loop > >> Write (Buffer (First..Buffer'Last), Last); > >> exit when Last =3D Buffer'Last; > >> First :=3D Last + 1; > >> end loop; > >> end Write; > > > > You forgot the "delay 0.0;" >=20 > I didn't. With yielding processor it would no more be busy-waiting. >=20 > > That, combined with proper tasking runtimes, would seem to provide bett= er > > results than doing all one thing (task =3D thread) or all othe ther (so= me > > fancy coroutine system). >=20 > Not really. The whole point is that in the imaginary case under=20 > consideration you don't need a timer event in order to wake Write up. I= =20 > presume that there is an I/O event that tells this: >=20 > procedure Write (Buffer : String) is > First : Integer :=3D Buffer'First; > Last : Integer; > begin > loop > Write (Buffer (First..Buffer'Last), Last); > exit when Last =3D Buffer'Last; > First :=3D Last + 1; > Output_Buffer.Wait_For_State (Not_Full); -- A PO's entry call > end loop; > end Write; =20 This procedure works correctly if the entire buffer is written. However, it= will not work as intended if partial buffer is written first. Thus, the ex= it statement will never be true. One of the fix is to replace it, after Fir= st is recalculated, with "exit when First > Buffer'Last" statement. Anh Vo