comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Ada-Oriented GUI
Date: Wed, 4 Apr 2018 09:30:11 +0200
Date: 2018-04-04T09:30:11+02:00	[thread overview]
Message-ID: <pa1uu3$1h48$1@gioia.aioe.org> (raw)
In-Reply-To: pa0ved$38o$1@gioia.aioe.org

On 04/04/2018 00:32, Robert I. Eachus wrote:
> On 4/3/2018 4:31 AM, Dmitry A. Kazakov wrote:
>>>
>>> Strange, this looks a lot like the interface to Text_IO. ;-)
>>
>> Yes, the idea is to have same interfaces.
>>
>>> The File has a controlled part to insure that when the File object 
>>> goes away, the File instance does too, and attempts to call Write 
>>> raise an exception. (Close should do nothing if the File is already 
>>> closed. ;-)  File type is limited to insure that copies are not made.
>>>
>>> What does a blocking package look like?  Much the same, except for 
>>> the name.  You don't need to create a task in the body with an entry 
>>> Write, but that is implementation detail. ;-)  If you want, you can 
>>> replace the task with a protected object to get co-routine semantics.
>>
>> My brain hurts too. I don't understand how this is not blocking. When 
>> Write is called it does not return until I/O is complete. Protected 
>> object or not, the caller is stuck there. Co-routines are supposed to 
>> steal the caller's task and pass it to another thread of control while 
>> awaiting for Write to complete.
>>
>> It is just tasking without time sharing and scheduling.
> 
> I hope we are in full agreement.  We just have a different picture of 
> what the Write procedure does.  So let me provide my version. To get 
> asynch semantics there is a task hidden in the body which has an entry 
> called by Write.  Let's use WT for the task, and WE for the entry. Write 
> will pass its parameters to WE and return.  WT looks like:
> 
>      task body WE is
>      begin
>          ... -- Set up output device.
>        loop
>          select
>            accept WE(...) do
>              ... -- Copy any by reference parameters. No potentially
>                  -- blocking actions please.
>            end WE;
>              .. -- do work here, such as multiple writes to disk.
>                 -- Blocking is not just allowed, it is expected.
>            or accept Close;
>              ... -- Normal file close. Blocking allowed.
>              exit;
>            or terminate;
>          end select;
>        end loop;
>      exception
>        -- Whatever is needed.
>      end WE;
> 
> This task is what does the asynch part of setup, Write, and Close.

No, that does not work. The task must handle multiple I/O operations 
running simultaneously. As an example consider a socket selector that 
handles 1000+ sockets. The goal is to write a thread of control for each 
of the sockets in a way one would do with a blocking socket but without 
1000+ tasks chocking the scheduler.

A socket selector tells its owner which socket can be read/written 
without blocking. The implementation should switch to the co-routine 
handling the socket, read or write a portion of the buffer provided in 
the "blocking" call done by the co-routine. If all buffer read/written 
it passes the control to the co-routine, which then handles the protocol 
a usual sequential way. The co-routine gives control up when it needs 
another portion of data from the socket and does next "blocking" call. 
When the buffer is not completed, the task services another socket and 
another co-routine. This is a kind of light-weight scheduler driven by 
I/O events rather than by clock.

> What happens if you want it to be possible for hundreds of write actions 
> to be pending?  Left as an exercise for the reader.  Hint: requeue ;-) 

No, that does not work either. Requeue re-queues a *task" of the caller 
side. The problem is that there is no task to re-queue.

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


  reply	other threads:[~2018-04-04  7:30 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
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 [this message]
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