MySQL 26.7.0
Source Code Documentation
dependency_adapter.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_CSA_DEPENDENCY_ADAPTER_H
25#define MYSQL_CSA_DEPENDENCY_ADAPTER_H
26
27#include <cstdint>
28#include <memory>
29#include <optional>
31
32namespace mysql::csa {
33
34class Dependency_adapter;
35/// @brief Unique pointer type for Dependency_adapter
36using Dependency_adapter_ptr = std::unique_ptr<Dependency_adapter>;
37
38/// @brief Class that resolves dependencies based on transaction sequence
39/// number and last committed. It returns id of dependent task for a
40/// dependency tracker in the scheduler
42 public:
43 /// @brief Alias for task identifier from scheduler
45 /// @brief Optional resolved task identifier
46 using Task_id_resolved = std::optional<Task_id>;
47 /// @brief Optional clock delay value
48 using Clock_delay = std::optional<uint64_t>;
49
50 /// @brief Virtual destructor
51 virtual ~Dependency_adapter() = default;
52
53 /// @brief Remember the worker pool size if needed. Default - unused
54 virtual void set_worker_num(uint32_t) {}
55
56 /// @brief Solves dependencies - figures out after which task a task with
57 /// the given id should run
58 /// @param id Task id
59 /// @param seq_num Transaction sequence number
60 /// @param commit_parent Transaction commit parent (LC)
61 /// @return A pair containing an optional clock delay and an optional resolved
62 /// task ID
63 virtual std::pair<Clock_delay, Task_id_resolved> solve(
64 Task_id id, int64_t seq_num, int64_t commit_parent) = 0;
65};
66
67} // namespace mysql::csa
68
69#endif // MYSQL_CSA_DEPENDENCY_ADAPTER_H
Class that resolves dependencies based on transaction sequence number and last committed.
Definition: dependency_adapter.h:41
std::optional< uint64_t > Clock_delay
Optional clock delay value.
Definition: dependency_adapter.h:48
virtual void set_worker_num(uint32_t)
Remember the worker pool size if needed. Default - unused.
Definition: dependency_adapter.h:54
virtual std::pair< Clock_delay, Task_id_resolved > solve(Task_id id, int64_t seq_num, int64_t commit_parent)=0
Solves dependencies - figures out after which task a task with the given id should run.
virtual ~Dependency_adapter()=default
Virtual destructor.
std::optional< Task_id > Task_id_resolved
Optional resolved task identifier.
Definition: dependency_adapter.h:46
Represents the identifier of a task ingested by the scheduler,.
Definition: task_id.h:41
Definition: channel.cpp:28
std::unique_ptr< Dependency_adapter > Dependency_adapter_ptr
Unique pointer type for Dependency_adapter.
Definition: dependency_adapter.h:36