mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
Scheduler.cpp
Go to the documentation of this file.
2
3
4using namespace m;
5
6
7std::atomic<uint64_t> Scheduler::Transaction::next_id_;
8
9bool Scheduler::autocommit (std::unique_ptr<ast::Command> command, Diagnostic &diag) {
10 auto t = begin_transaction();
11 auto res_future = schedule_command(*t, std::move(command), diag);
12 res_future.wait();
13 if (res_future.get()) {
14 bool res = commit(std::move(t));
15 M_insist(res);
16 return res;
17 } else {
18 bool aborted = abort(std::move(t));
19 M_insist(aborted);
20 return false;
21 }
22}
#define M_insist(...)
Definition: macro.hpp:129
‍mutable namespace
Definition: Backend.hpp:10
static std::atomic< uint64_t > next_id_
‍Stores the next available Transaction ID, stored atomically to prevent race conditions
Definition: Scheduler.hpp:24
virtual std::unique_ptr< Transaction > begin_transaction()=0
Returns a new Scheduler::Transaction object that is passed along when scheduling commands.
virtual bool commit(std::unique_ptr< Transaction > t)=0
Closes the given Scheduler::Transaction and commits its changes.
bool autocommit(std::unique_ptr< ast::Command > command, Diagnostic &diag)
Schedule a ast::Command for execution and automatically commits its changes.
Definition: Scheduler.cpp:9
virtual bool abort(std::unique_ptr< Transaction > t)=0
Closes the given Scheduler::Transaction and discards its changes.
virtual std::future< bool > schedule_command(Transaction &t, std::unique_ptr< ast::Command > command, Diagnostic &diag)=0
Schedule a ast::Command for execution within the given Scheduler::Transaction.