mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
Data Structures | Public Member Functions | Protected Types | Static Private Member Functions | Private Attributes | Static Private Attributes
m::SerialScheduler Struct Reference

This class implements a Scheduler that executes all incoming DatabaseCommands serially. More...

#include <SerialScheduler.hpp>

Inheritance diagram for m::SerialScheduler:
[legend]
Collaboration diagram for m::SerialScheduler:
[legend]

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< Transactionbegin_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
 

Detailed Description

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.

Member Typedef Documentation

◆ queued_command

using m::Scheduler::queued_command = std::tuple<Transaction &, std::unique_ptr<ast::Command>, Diagnostic &, std::promise<bool> >
protectedinherited

Definition at line 38 of file Scheduler.hpp.

Constructor & Destructor Documentation

◆ SerialScheduler()

m::SerialScheduler::SerialScheduler ( )
default

◆ ~SerialScheduler()

SerialScheduler::~SerialScheduler ( )

Member Function Documentation

◆ abort()

bool SerialScheduler::abort ( std::unique_ptr< Transaction t)
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().

◆ autocommit()

bool Scheduler::autocommit ( std::unique_ptr< ast::Command command,
Diagnostic diag 
)
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().

◆ begin_transaction()

std::unique_ptr< SerialScheduler::Transaction > SerialScheduler::begin_transaction ( )
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.

◆ commit()

bool SerialScheduler::commit ( std::unique_ptr< Transaction t)
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().

◆ schedule_command()

std::future< bool > SerialScheduler::schedule_command ( Transaction t,
std::unique_ptr< ast::Command command,
Diagnostic diag 
)
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_.

◆ schedule_thread()

void SerialScheduler::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().

Field Documentation

◆ next_start_time

std::atomic< int64_t > SerialScheduler::next_start_time = 0
staticprivate

stores the next transaction start time

Definition at line 46 of file SerialScheduler.hpp.

Referenced by schedule_thread().

◆ query_queue_

SerialScheduler::CommandQueue SerialScheduler::query_queue_
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().

◆ schedule_thread_

std::thread m::SerialScheduler::schedule_thread_
private

the worker thread that executes all incoming queries.

Definition at line 44 of file SerialScheduler.hpp.

Referenced by schedule_command(), and ~SerialScheduler().


The documentation for this struct was generated from the following files: