MySQL 26.7.0
Source Code Documentation
delayed_schedule.h
Go to the documentation of this file.
1// Copyright (c) 2026, Oracle and/or its affiliates.
2//
3// This program is free software; you can redistribute it and/or modify
4// it under the terms of the GNU General Public License, version 2.0,
5// as published by the Free Software Foundation.
6//
7// This program is designed to work with certain software (including
8// but not limited to OpenSSL) that is licensed under separate terms,
9// as designated in a particular file or component or in included license
10// documentation. The authors of MySQL hereby grant you an additional
11// permission to link the program and your derivative works with the
12// separately licensed software that they have either included with
13// the program or referenced in the documentation.
14//
15// This program is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License, version 2.0, for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with this program; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23
24#ifndef MYSQL_SCHEDULER_DELAYED_SCHEDULE_H
25#define MYSQL_SCHEDULER_DELAYED_SCHEDULE_H
26
27#include <chrono>
28#include <iostream>
29#include <memory>
30#include <string>
31
35
36namespace mysql::scheduler {
37
38/// @class Delayed_schedule
39/// @brief Represents Schedule for one-shot, delayed task
41 public:
42 /// @brief Constructor
43 /// @details constructs schedule with delay us from the clock start point
44 /// @param task_id Task identifier
45 /// @param clock Scheduler clock
46 /// @param delay Delay in microseconds
47 Delayed_schedule(Task_id task_id, Scheduler_clock_ptr clock, uint64_t delay);
48
49 /// @brief This function modifies the state of the schedule to next state
50 /// @returns false - Task is one-shot task, won't be executed in the future
51 bool next() override;
52
53 /// @brief Gets information about next execution time
54 /// @returns Current phase task delay
55 const Time_delay_type &get_task_delay() const override;
56
57 bool is_finished() const override { return true; }
58
59 /// @brief Obtain task clock
60 const Scheduler_clock_ptr &get_clock() const override;
61
62 /// @brief Obtain task id
63 const Task_id &get_id() const override;
64
65 protected:
66 private:
67 /// This task id
69 /// Clock this schedule is based on
71 /// Delay since clock start point
72 uint64_t m_task_delay;
73};
74
75} // namespace mysql::scheduler
76
77#endif // MYSQL_SCHEDULER_DELAYED_SCHEDULE_H
Represents Schedule for one-shot, delayed task.
Definition: delayed_schedule.h:40
bool next() override
This function modifies the state of the schedule to next state.
Definition: delayed_schedule.cpp:35
const Scheduler_clock_ptr & get_clock() const override
Obtain task clock.
Definition: delayed_schedule.cpp:41
uint64_t m_task_delay
Delay since clock start point.
Definition: delayed_schedule.h:72
const Time_delay_type & get_task_delay() const override
Gets information about next execution time.
Definition: delayed_schedule.cpp:37
bool is_finished() const override
Definition: delayed_schedule.h:57
Scheduler_clock_ptr m_clock
Clock this schedule is based on.
Definition: delayed_schedule.h:70
Delayed_schedule(Task_id task_id, Scheduler_clock_ptr clock, uint64_t delay)
Constructor.
Definition: delayed_schedule.cpp:31
const Task_id & get_id() const override
Obtain task id.
Definition: delayed_schedule.cpp:45
Task_id m_task_id
This task id.
Definition: delayed_schedule.h:68
Represents the identifier of a task ingested by the scheduler,.
Definition: task_id.h:41
Represents task schedule.
Definition: task_schedule.h:45
Definition: base_dependency_tracker.h:41
std::uint64_t Time_delay_type
Time points are created as a delay from a specific start time (clock relative measure)
Definition: time.h:39
std::shared_ptr< Scheduler_clock > Scheduler_clock_ptr
Definition: scheduler_clock.h:36