Currently it is impossible to use Ada.Real_Time.Timing_Events with a protected object inside a procedure, generic package, etc. due to Timing_Event_Handler having a global accessibility level. There is however an easy fix for this: Optionally allow the handler to be defined as a discriminant on Timing_Event, or rather on a new type to maintain compatibility with any existing code. i.e. type New_Timing_Event (Handler : access protected procedure (Event : Timing_Event_Access)) is tagged limited private;.
One could of course implement this themselves, but since Timing_Events is already here I think it makes sense to have a more accessibility-friendly version.
Another option would be to have an exact copy of Ada.Real_Time.Timing_Events as a generic package, but this is less flexible in a few ways, notably if a protected type wants to hold a timing event as a component which it uses to refer to itself.
Currently it is impossible to use
Ada.Real_Time.Timing_Eventswith a protected object inside a procedure, generic package, etc. due toTiming_Event_Handlerhaving a global accessibility level. There is however an easy fix for this: Optionally allow the handler to be defined as a discriminant onTiming_Event, or rather on a new type to maintain compatibility with any existing code. i.e.type New_Timing_Event (Handler : access protected procedure (Event : Timing_Event_Access)) is tagged limited private;.One could of course implement this themselves, but since
Timing_Eventsis already here I think it makes sense to have a more accessibility-friendly version.Another option would be to have an exact copy of
Ada.Real_Time.Timing_Eventsas a generic package, but this is less flexible in a few ways, notably if a protected type wants to hold a timing event as a component which it uses to refer to itself.