comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Designing Timers using Ada.Real_Time.Timing_Events package
Date: Sun, 26 Mar 2006 14:58:52 +0200
Date: 2006-03-26T14:58:49+02:00	[thread overview]
Message-ID: <1fiau0e4pe84o$.gulfgysczk5i$.dlg@40tude.net> (raw)
In-Reply-To: 1143351567.528574.297850@z34g2000cwc.googlegroups.com

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



  reply	other threads:[~2006-03-26 12:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-25 20:03 Designing Timers using Ada.Real_Time.Timing_Events package Anh Vo
2006-03-25 20:58 ` Dmitry A. Kazakov
2006-03-26  5:39   ` Anh Vo
2006-03-26 12:58     ` Dmitry A. Kazakov [this message]
2006-03-26 16:18       ` Anh Vo
2006-03-26 18:22         ` Dmitry A. Kazakov
2006-03-26 19:43           ` Anh Vo
     [not found]             ` <3itd22hcekts5lsojdqjnn966bbvc8fckh@4ax.com>
2006-03-26 23:53               ` Anh Vo
     [not found]                 ` <0mae22lshe5nee8pt8h7seussloebv07g3@4ax.com>
2006-03-27  5:01                   ` Anh Vo
     [not found]                     ` <5vse22h4mc1och27s0nkbv986csi2rorki@4ax.com>
2006-03-28  0:07                       ` Anh Vo
2006-03-27  7:49             ` Dmitry A. Kazakov
2006-03-27 18:14               ` Dmitry A. Kazakov
2006-03-27 22:00                 ` Anh Vo
2006-03-28  7:51                   ` Dmitry A. Kazakov
2006-03-28 16:00                     ` Anh Vo
2006-03-26  7:59 ` Martin Krischik
2006-03-26 15:50   ` Anh Vo
replies disabled

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