comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: How to make a task wait and resume ?
Date: Fri, 18 Jan 2019 11:20:40 +0100
Date: 2019-01-18T11:20:40+01:00	[thread overview]
Message-ID: <q1s99o$1sv2$2@gioia.aioe.org> (raw)
In-Reply-To: caf4e246-030d-4da5-8c7d-db89497caaf6@googlegroups.com

On 2019-01-18 08:59, reinert wrote:
> I suspected to be missing something :-)
> 
> In my case, a user is normally actively interacting with the actual program
> which is about treating a large sequence of images. The user can start/stop
> a task which reads in images upfront to avoid waiting time. If the computer
> is weak (small ram) he/she sometimes has to stop the reading (and the program automatically "clean" memory) and probably resume later. Hence the "synchronization" here is not with other tasks.

This looks more like a classic Ada tasking (AKA monitors):

task body Reader is
    Buffer : Stream_Element_Array (1..Size);
    Last   : Stream_Element_Offset;
    File   : File_Type;
begin
    loop
      -- accept new file, open it
      begin
         loop
            Read (File.Stream, Buffer, Last);
            -- cache portion of file in Buffer (1..Last)
            select
               accept Forget_It;
               -- close file, clean up
               exit;
            else
               null;
            end select;
          end loop;
       exception
          when End_Error =>
             -- close file
    end loop;
end Reader;

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


      reply	other threads:[~2019-01-18 10:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-17 16:21 How to make a task wait and resume ? reinert
2019-01-17 17:28 ` Dmitry A. Kazakov
2019-01-17 22:28   ` Randy Brukardt
2019-01-18  7:59     ` reinert
2019-01-18 10:20       ` Dmitry A. Kazakov [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox