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 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Natasha Kerensikova Newsgroups: comp.lang.ada Subject: Termination of periodic tasks Date: Sun, 15 Jun 2014 10:10:20 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: Injection-Date: Sun, 15 Jun 2014 10:10:20 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="76a49b86bc3e16725b7cfca3d85cb4c8"; logging-data="22568"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19L8AiuB8cUrmsyuTozFDFR" User-Agent: slrn/1.0.1 (FreeBSD) Cancel-Lock: sha1:NGpfi79EviFxv8+NG15+1qBSPhI= Xref: news.eternal-september.org comp.lang.ada:20315 Date: 2014-06-15T10:10:20+00:00 List-Id: Hello, I'm still struggling with the termination of tasks hidden in the private part or the body of libraries, this time with a periodic task. Basically, I'm looking for a way to have some subprogram called at roughly regular intervals. Ada.Real_Time.Timing_Events would be functionally what I needed, except it's accuracy is vastly more than I need, so it's overhead is mostly wasted. For the uses I currently have in mind, the periodic subprogram would be a kind of GC for slowly moving resources, called every 15 min to every day, with a time tolerance exceeding minutes. While in GNARL Ada.Real_Time.Timing_Events is implemented using a task awaken every 100 ms. And same as before, the task should be able to terminate quickly when the program terminates. I would be perfectly happy with something like: task body Periodic_Task is loop select delay 86_400.0; or terminate; end select; Periodic_Subprogram; end loop; end task; Except that's not available in Ada. The "or terminate" part is only available when waiting for an entry, but this only move the problem to the periodic calling of the entry. A timed select to wait for an entry that exists the loop would be fine too, but how can I detect program termination to call the entry? Could something be worked with a user-defined Finalize? I looked at how GNARL is doing it, but it's using an RL-specific primitive to move the task one level above the main master, so that it's aborted instead of waited-for on program termination. I'm a bit reluctant to use a RL-internal primitive... That leaves Ada.Real_Time.Timing_Events and its comparatively large overhead, even though (I think) I can afford it, it's not very satisfying. How would you do it? Thanks in advance for your help, Natasha