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

A thread-safe query plan queue. More...

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

Public Member Functions

 CommandQueue ()=default
 
 ~CommandQueue ()=default
 
std::optional< queued_commandpop ()
 

‍returns the next queued ast::Command. Returns std::nullopt if the queue is closed.


 
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::Commands.
 
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_commandcommand_list_
 
Transactionrunning_transaction_
 the currently running transaction. Only commands by this transaction are returned.
 
std::mutex mutex_
 
std::condition_variable has_element_
 
bool closed_ = false
 

Detailed Description

A thread-safe query plan queue.

Definition at line 19 of file SerialScheduler.hpp.

Constructor & Destructor Documentation

◆ CommandQueue()

m::SerialScheduler::CommandQueue::CommandQueue ( )
default

◆ ~CommandQueue()

m::SerialScheduler::CommandQueue::~CommandQueue ( )
default

Member Function Documentation

◆ close()

void SerialScheduler::CommandQueue::close ( )

empties and closes the queue without executing the remaining ast::Commands.

Definition at line 65 of file SerialScheduler.cpp.

Referenced by m::SerialScheduler::~SerialScheduler().

◆ is_closed()

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().

◆ pop()

std::optional< m::Scheduler::queued_command > SerialScheduler::CommandQueue::pop ( )

‍returns the next queued ast::Command. Returns std::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().

◆ push()

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().

◆ stop_transaction()

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().

Field Documentation

◆ closed_

bool m::SerialScheduler::CommandQueue::closed_ = false
private

Definition at line 26 of file SerialScheduler.hpp.

Referenced by is_closed(), and pop().

◆ command_list_

std::list<queued_command> m::SerialScheduler::CommandQueue::command_list_
private

Definition at line 22 of file SerialScheduler.hpp.

Referenced by pop().

◆ has_element_

std::condition_variable m::SerialScheduler::CommandQueue::has_element_
private

Definition at line 25 of file SerialScheduler.hpp.

Referenced by pop().

◆ mutex_

std::mutex m::SerialScheduler::CommandQueue::mutex_
private

Definition at line 24 of file SerialScheduler.hpp.

Referenced by pop().

◆ running_transaction_

Transaction* m::SerialScheduler::CommandQueue::running_transaction_
private

the currently running transaction. Only commands by this transaction are returned.

Definition at line 23 of file SerialScheduler.hpp.

Referenced by pop().


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