![]() |
mutable
A Database System for Research and Fast Prototyping
|
This class implements a Scheduler that executes all incoming DatabaseCommands serially.
More...
#include <SerialScheduler.hpp>
Data Structures | |
| struct | CommandQueue |
| A thread-safe query plan queue. More... | |
Public Member Functions | |
| SerialScheduler ()=default | |
| ~SerialScheduler () | |
| std::future< bool > | schedule_command (Transaction &t, std::unique_ptr< ast::Command > command, Diagnostic &diag) override |
Schedule a ast::Command for execution within the given Scheduler::Transaction. | |
| std::unique_ptr< Transaction > | begin_transaction () override |
Returns a new Scheduler::Transaction object that is passed along when scheduling commands. | |
| bool | commit (std::unique_ptr< Transaction > t) override |
Closes the given Scheduler::Transaction and commits its changes. | |
| bool | abort (std::unique_ptr< Transaction > t) override |
Closes the given Scheduler::Transaction and discards its changes. | |
| bool | autocommit (std::unique_ptr< ast::Command > command, Diagnostic &diag) |
Schedule a ast::Command for execution and automatically commits its changes. | |
Protected Types | |
| using | queued_command = std::tuple< Transaction &, std::unique_ptr< ast::Command >, Diagnostic &, std::promise< bool > > |
Static Private Member Functions | |
| static void | schedule_thread () |
The method run by the worker thread schedule_thread_. | |
Private Attributes | |
| std::thread | schedule_thread_ |
| the worker thread that executes all incoming queries. | |
Static Private Attributes | |
| static CommandQueue | query_queue_ |
| instance of our thread-safe query queue that stores all incoming plans. | |
| static std::atomic< int64_t > | next_start_time = 0 |
| stores the next transaction start time | |
This class implements a Scheduler that executes all incoming DatabaseCommands serially.
This means that there is no concurrent execution. Therefore, a consistent, serial execution of multiple queries is guaranteed.
Definition at line 15 of file SerialScheduler.hpp.
|
protectedinherited |
Definition at line 38 of file Scheduler.hpp.
|
default |
| SerialScheduler::~SerialScheduler | ( | ) |
Definition at line 94 of file SerialScheduler.cpp.
References m::SerialScheduler::CommandQueue::close(), query_queue_, and schedule_thread_.
|
overridevirtual |
Closes the given Scheduler::Transaction and discards its changes.
Returns true if the changes were undone successfully.
Implements m::Scheduler.
Definition at line 125 of file SerialScheduler.cpp.
References query_queue_, and m::SerialScheduler::CommandQueue::stop_transaction().
|
inherited |
Schedule a ast::Command for execution and automatically commits its changes.
Returns true if the ast::Command was executed and its changes were committed successfully.
Definition at line 9 of file Scheduler.cpp.
References m::Scheduler::abort(), m::Scheduler::begin_transaction(), m::Scheduler::commit(), M_insist, and m::Scheduler::schedule_command().
Referenced by m::process_stream().
|
overridevirtual |
Returns a new Scheduler::Transaction object that is passed along when scheduling commands.
Implements m::Scheduler.
Definition at line 114 of file SerialScheduler.cpp.
|
overridevirtual |
Closes the given Scheduler::Transaction and commits its changes.
Returns true if the changes were committed successfully.
Implements m::Scheduler.
Definition at line 118 of file SerialScheduler.cpp.
References query_queue_, and m::SerialScheduler::CommandQueue::stop_transaction().
|
overridevirtual |
Schedule a ast::Command for execution within the given Scheduler::Transaction.
Returns a std:future<bool> that is set to true if the ast::Command was successfully executed, false otherwise.
Implements m::Scheduler.
Definition at line 102 of file SerialScheduler.cpp.
References m::SerialScheduler::CommandQueue::push(), query_queue_, schedule_thread(), and schedule_thread_.
|
staticprivate |
The method run by the worker thread schedule_thread_.
While stopping, the query that is already being executed will complete its execution but queued queries will not be executed.
Definition at line 131 of file SerialScheduler.cpp.
References m::ast::Sema::analyze(), m::and, m::Catalog::Get(), m::SerialScheduler::CommandQueue::is_closed(), M_insist, M_unreachable, next_start_time, m::SerialScheduler::CommandQueue::pop(), and query_queue_.
Referenced by schedule_command().
|
staticprivate |
stores the next transaction start time
Definition at line 46 of file SerialScheduler.hpp.
Referenced by schedule_thread().
|
staticprivate |
instance of our thread-safe query queue that stores all incoming plans.
Definition at line 43 of file SerialScheduler.hpp.
Referenced by abort(), commit(), m::SerialScheduler::CommandQueue::is_closed(), m::SerialScheduler::CommandQueue::pop(), schedule_command(), schedule_thread(), and ~SerialScheduler().
|
private |
the worker thread that executes all incoming queries.
Definition at line 44 of file SerialScheduler.hpp.
Referenced by schedule_command(), and ~SerialScheduler().