Index: src/natools-cron.adb ================================================================== --- src/natools-cron.adb +++ src/natools-cron.adb @@ -79,10 +79,21 @@ return Result : Cron_Entry do Result.Set (Time, Callback); end return; end Create; + + function Create + (Origin : in Ada.Calendar.Time; + Callback : in Cron.Callback'Class) + return Cron_Entry is + begin + return Result : Cron_Entry do + Result.Set (Origin, Callback); + end return; + end Create; + function Create (Period : in Duration; Callback : in Cron.Callback'Class) return Cron_Entry is @@ -108,10 +119,19 @@ Self.Reset; Self.Callback.Replace (Create'Access); Database.Insert (Time, Self.Callback); end Set; + + procedure Set + (Self : in out Cron_Entry; + Origin : in Ada.Calendar.Time; + Callback : in Cron.Callback'Class) is + begin + Set (Self, (Origin, 0.0), Callback); + end Set; + procedure Set (Self : in out Cron_Entry; Period : in Duration; Callback : in Cron.Callback'Class) is Index: src/natools-cron.ads ================================================================== --- src/natools-cron.ads +++ src/natools-cron.ads @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ --- Copyright (c) 2014, Natacha Porté -- +-- Copyright (c) 2014-2015, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- @@ -52,10 +52,16 @@ (Time : in Periodic_Time; Callback : in Cron.Callback'Class) return Cron_Entry; -- Create a new entry with the given parameters + function Create + (Origin : in Ada.Calendar.Time; + Callback : in Cron.Callback'Class) + return Cron_Entry; + -- Create a new entry that executes only once, at the given time + function Create (Period : in Duration; Callback : in Cron.Callback'Class) return Cron_Entry; -- Create a new entry starting within a period from now @@ -64,10 +70,16 @@ (Self : in out Cron_Entry; Time : in Periodic_Time; Callback : in Cron.Callback'Class); -- Reset an entry with the given parameters + procedure Set + (Self : in out Cron_Entry; + Origin : in Ada.Calendar.Time; + Callback : in Cron.Callback'Class); + -- Reset entry with the given parameters, running only once + procedure Set (Self : in out Cron_Entry; Period : in Duration; Callback : in Cron.Callback'Class); -- Reset entry with the given parameters, starting one period from now