![]() |
mutable
A Database System for Research and Fast Prototyping
|
A thread-safe query plan queue. More...
Public Member Functions | |
CommandQueue ()=default | |
~CommandQueue ()=default | |
std::optional< queued_command > | pop () |
| |
void | push (Transaction &t, std::unique_ptr< ast::Command > command, Diagnostic &diag, std::promise< bool > promise) |
Inserts the command into the queue. | |
void | close () |
empties and closes the queue without executing the remaining ast::Command s. | |
bool | is_closed () |
signals waiting threads that no more elements will be pushed | |
void | stop_transaction (Transaction &t) |
Marks t as no longer running. | |
Private Attributes | |
std::list< queued_command > | command_list_ |
Transaction * | running_transaction_ |
the currently running transaction. Only commands by this transaction are returned. | |
std::mutex | mutex_ |
std::condition_variable | has_element_ |
bool | closed_ = false |
A thread-safe query plan queue.
Definition at line 19 of file SerialScheduler.hpp.
|
default |
|
default |
void SerialScheduler::CommandQueue::close | ( | ) |
empties and closes the queue without executing the remaining ast::Command
s.
Definition at line 65 of file SerialScheduler.cpp.
Referenced by m::SerialScheduler::~SerialScheduler().
bool SerialScheduler::CommandQueue::is_closed | ( | ) |
signals waiting threads that no more elements will be pushed
Definition at line 77 of file SerialScheduler.cpp.
References closed_, and m::SerialScheduler::query_queue_.
Referenced by m::SerialScheduler::schedule_thread().
std::optional< m::Scheduler::queued_command > SerialScheduler::CommandQueue::pop | ( | ) |
returns the next queued
ast::Command
. Returnsstd::nullopt
if the queue is closed.
Definition at line 9 of file SerialScheduler.cpp.
References closed_, command_list_, has_element_, mutex_, m::SerialScheduler::query_queue_, and running_transaction_.
Referenced by m::SerialScheduler::schedule_thread().
void SerialScheduler::CommandQueue::push | ( | Transaction & | t, |
std::unique_ptr< ast::Command > | command, | ||
Diagnostic & | diag, | ||
std::promise< bool > | promise | ||
) |
Inserts the command into the queue.
Internally the position in the command_list_
is determined by the start time of Transaction t
. A smaller start time is inserted before a larger start time and elements with the same start time are ordered in FIFO order by the time of arrival.
Definition at line 39 of file SerialScheduler.cpp.
References m::and.
Referenced by m::SerialScheduler::schedule_command().
void SerialScheduler::CommandQueue::stop_transaction | ( | Transaction & | t | ) |
Marks t
as no longer running.
Definition at line 83 of file SerialScheduler.cpp.
References M_insist.
Referenced by m::SerialScheduler::abort(), and m::SerialScheduler::commit().
|
private |
Definition at line 26 of file SerialScheduler.hpp.
Referenced by is_closed(), and pop().
|
private |
Definition at line 22 of file SerialScheduler.hpp.
Referenced by pop().
|
private |
Definition at line 25 of file SerialScheduler.hpp.
Referenced by pop().
|
private |
Definition at line 24 of file SerialScheduler.hpp.
Referenced by pop().
|
private |
the currently running transaction. Only commands by this transaction are returned.
Definition at line 23 of file SerialScheduler.hpp.
Referenced by pop().