MySQL 9.3.0
Source Code Documentation
shcore::polyglot::Garbage_collector Class Referencefinal

The Garbage Collection logic is determined by the occurrence of events such as: More...

#include <polyglot_garbage_collector.h>

Classes

struct  Config
 

Public Types

enum class  Event { EXECUTED_STATEMENT , TERMINATED_LANGUAGE , TERMINATE }
 
using Time_point = std::chrono::time_point< std::chrono::system_clock >
 

Public Member Functions

 Garbage_collector ()=default
 
 ~Garbage_collector ()
 
 Garbage_collector (const Garbage_collector &other)=delete
 
 Garbage_collector (Garbage_collector &&other)=delete
 
Garbage_collectoroperator= (const Garbage_collector &other)=delete
 
Garbage_collectoroperator= (Garbage_collector &&other)=delete
 
void notify (Event event)
 
void start (Config &&config, poly_isolate isolate)
 
void stop ()
 

Private Types

enum class  State { INITIAL , STARTED , TERMINATED , ERROR }
 

Private Member Functions

void run (poly_isolate isolate)
 
void set_state (State state, const std::string &error="")
 

Private Attributes

std::mutex m_mutex
 
std::mutex m_state_mutex
 
std::condition_variable m_condition
 
std::unique_ptr< std::thread > m_thread
 
State m_state = State::INITIAL
 
std::string m_error
 
Config m_config
 
bool m_terminated = false
 
size_t m_statement_count = 0
 
size_t m_language_count = 0
 
Time_point m_last_gctime
 

Detailed Description

The Garbage Collection logic is determined by the occurrence of events such as:

  • Statements being executed
  • Language instances being disposed
  • Completion of predefined time lapse

The trigger for GC operations is defined by the following optional configurations:

  • Minimal interval (seconds): if defined, the GC will NOT be executed in periods shorter than this interval.
  • Minimal executed statements: if defined, the GC will not be executed if less than the defined number of statements has been executed.
  • Minimal language instances: if defined, the GC will not be executed if less than the defined number of language instances have been terminated.

Additionally, when the garbage collector may be stopped (i.e. when terminating the application), in such case, a GC operation will be triggered despite the state of the configurable options.

This class keeps the Garbage Collection configuration and executes GC in a separate thread based on the configuration and reported events.

Member Typedef Documentation

◆ Time_point

using shcore::polyglot::Garbage_collector::Time_point = std::chrono::time_point<std::chrono::system_clock>

Member Enumeration Documentation

◆ Event

Enumerator
EXECUTED_STATEMENT 
TERMINATED_LANGUAGE 
TERMINATE 

◆ State

Enumerator
INITIAL 
STARTED 
TERMINATED 
ERROR 

Constructor & Destructor Documentation

◆ Garbage_collector() [1/3]

shcore::polyglot::Garbage_collector::Garbage_collector ( )
default

◆ ~Garbage_collector()

shcore::polyglot::Garbage_collector::~Garbage_collector ( )

◆ Garbage_collector() [2/3]

shcore::polyglot::Garbage_collector::Garbage_collector ( const Garbage_collector other)
delete

◆ Garbage_collector() [3/3]

shcore::polyglot::Garbage_collector::Garbage_collector ( Garbage_collector &&  other)
delete

Member Function Documentation

◆ notify()

void shcore::polyglot::Garbage_collector::notify ( Event  event)

◆ operator=() [1/2]

Garbage_collector & shcore::polyglot::Garbage_collector::operator= ( const Garbage_collector other)
delete

◆ operator=() [2/2]

Garbage_collector & shcore::polyglot::Garbage_collector::operator= ( Garbage_collector &&  other)
delete

◆ run()

void shcore::polyglot::Garbage_collector::run ( poly_isolate  isolate)
private

◆ set_state()

void shcore::polyglot::Garbage_collector::set_state ( State  state,
const std::string &  error = "" 
)
private

◆ start()

void shcore::polyglot::Garbage_collector::start ( Config &&  config,
poly_isolate  isolate 
)

◆ stop()

void shcore::polyglot::Garbage_collector::stop ( )

Member Data Documentation

◆ m_condition

std::condition_variable shcore::polyglot::Garbage_collector::m_condition
private

◆ m_config

Config shcore::polyglot::Garbage_collector::m_config
private

◆ m_error

std::string shcore::polyglot::Garbage_collector::m_error
private

◆ m_language_count

size_t shcore::polyglot::Garbage_collector::m_language_count = 0
private

◆ m_last_gctime

Time_point shcore::polyglot::Garbage_collector::m_last_gctime
private

◆ m_mutex

std::mutex shcore::polyglot::Garbage_collector::m_mutex
private

◆ m_state

State shcore::polyglot::Garbage_collector::m_state = State::INITIAL
private

◆ m_state_mutex

std::mutex shcore::polyglot::Garbage_collector::m_state_mutex
private

◆ m_statement_count

size_t shcore::polyglot::Garbage_collector::m_statement_count = 0
private

◆ m_terminated

bool shcore::polyglot::Garbage_collector::m_terminated = false
private

◆ m_thread

std::unique_ptr<std::thread> shcore::polyglot::Garbage_collector::m_thread
private

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