Natools

Check-in [c9ed8bd1e7]
Login
Overview
Comment:cron: use non-positive periods to mean non-repeating events
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c9ed8bd1e7386e708b02aa66beba42e5acfaf08b
User & Date: nat on 2015-11-14 18:12:49
Other Links: manifest | tags
Context
2015-11-16
18:10
cron: add constructor and mutator for one-time events check-in: 61163cf23d user: nat tags: trunk
2015-11-14
18:12
cron: use non-positive periods to mean non-repeating events check-in: c9ed8bd1e7 user: nat tags: trunk
2015-11-12
18:08
s_expressions-templates-dates: fix incorrect weekday w.r.t. time zone check-in: 57cb40c5fb user: nat tags: trunk
Changes

Modified src/natools-cron.adb from [97e2735033] to [70b9a5b0ce].

1
2
3
4
5
6
7
8
9
------------------------------------------------------------------------------
-- Copyright (c) 2014, 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.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --

|







1
2
3
4
5
6
7
8
9
------------------------------------------------------------------------------
-- 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.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --
148
149
150
151
152
153
154

155
156
157

158
159
160
161
162
163
164
         Callback : in Callback_Refs.Reference)
      is
         use type Ada.Calendar.Time;

         Now : constant Ada.Calendar.Time := Ada.Calendar.Clock;
         Actual_Time : Periodic_Time := Time;
      begin

         while Actual_Time.Origin < Now loop
            Actual_Time.Origin := Actual_Time.Origin + Actual_Time.Period;
         end loop;


         if Map.Is_Empty then
            if Global_Worker /= null and then Global_Worker.all'Terminated then
               Unchecked_Free (Global_Worker);
            end if;

            if Global_Worker = null then







>
|
|
|
>







148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
         Callback : in Callback_Refs.Reference)
      is
         use type Ada.Calendar.Time;

         Now : constant Ada.Calendar.Time := Ada.Calendar.Clock;
         Actual_Time : Periodic_Time := Time;
      begin
         if Actual_Time.Period > 0.0 then
            while Actual_Time.Origin < Now loop
               Actual_Time.Origin := Actual_Time.Origin + Actual_Time.Period;
            end loop;
         end if;

         if Map.Is_Empty then
            if Global_Worker /= null and then Global_Worker.all'Terminated then
               Unchecked_Free (Global_Worker);
            end if;

            if Global_Worker = null then
254
255
256
257
258
259
260


261

262
263
264
265
266
267
268
         Search :
         while Entry_Maps.Has_Element (Cursor) loop
            if Entry_Maps.Element (Cursor) = Callback then
               declare
                  Old_Time : constant Periodic_Time := Entry_Maps.Key (Cursor);
               begin
                  Map.Delete (Cursor);


                  Insert (Old_Time, Callback);

               end;

               exit Search;
            end if;

            Entry_Maps.Next (Cursor);
         end loop Search;







>
>
|
>







256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
         Search :
         while Entry_Maps.Has_Element (Cursor) loop
            if Entry_Maps.Element (Cursor) = Callback then
               declare
                  Old_Time : constant Periodic_Time := Entry_Maps.Key (Cursor);
               begin
                  Map.Delete (Cursor);

                  if Old_Time.Period > 0.0 then
                     Insert (Old_Time, Callback);
                  end if;
               end;

               exit Search;
            end if;

            Entry_Maps.Next (Cursor);
         end loop Search;