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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5b15c37c5d0c986f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!tudelft.nl!txtfeed1.tudelft.nl!feeder1.cambrium.nl!feed.tweaknews.nl!news.netcologne.de!nhp.netcologne.de!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Designing Timers using Ada.Real_Time.Timing_Events package Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1143317010.868435.251190@v46g2000cwv.googlegroups.com> <1d4yew2i587h5.1h8dilwbda4zv.dlg@40tude.net> <1143351567.528574.297850@z34g2000cwc.googlegroups.com> Date: Sun, 26 Mar 2006 14:58:52 +0200 Message-ID: <1fiau0e4pe84o$.gulfgysczk5i$.dlg@40tude.net> NNTP-Posting-Date: 26 Mar 2006 14:58:49 MEST NNTP-Posting-Host: d0058ab1.newsread2.arcor-online.net X-Trace: DXC=;^DiTh[_A@LfS]5RcNSd9MQ5U85hF6f;DjW\KbG]kaMHDAHcn;Zl5eH87KnSJVbI_J[6LHn;2LCVN[ On 25 Mar 2006 21:39:27 -0800, Anh Vo wrote: >> You can also use protected objects functionality rather than turn to >> callbacks (which are always difficult to get right in presence on multiple >> tasks.) A protected object may act as an waitable event triggered by the >> timer via a call to its protected procedure and reset in its entry point >> "Wait." This would be deadlock-free because anything the waiting task >> should do upon the event would happen outside the protected action. > > I did not know that it is possible to use protected objects > functionally while each timer used for different purpose. Could you > elaborate further? Why not? Each protected object would be a simple event. The handler set for Ada.Real_Time.Timing_Events triggers an event(s). The functionality, i.e. what has to be done upon the event, is outside. It happens in the task waiting for the event. (I don't have GNAT GPL installed) >> In a separate package you could wrap the task and the protected object in a >> abstract limited tagged type with the primitive operation "On_Event" to >> override (if you definitely want callbacks.) > > I am not sure what advantage gained for doing this way? Decoupling. The model one task - one callback is too specialized and exposed to misuse. You might wish to have more than one task, you might want handling the timer events on different contexts, routing and re-routing them between tasks. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de