MySQL 9.3.0
Source Code Documentation
shcore::polyglot::Collectable_registry Class Reference

When a Polyglot wrapper for a C++ object is created, a collectable instance is created to be passed to the Polyglot object (Java). More...

#include <polyglot_collectable.h>

Public Member Functions

 Collectable_registry ()=default
 
 Collectable_registry (const Collectable_registry &)=delete
 
 Collectable_registry (Collectable_registry &&)=delete
 
Collectable_registryoperator= (const Collectable_registry &)=delete
 
Collectable_registryoperator= (Collectable_registry &&)=delete
 
 ~Collectable_registry ()
 
void add (ICollectable *target)
 
void remove (ICollectable *target)
 
void clean ()
 Deletes all collectables which were marked as to be deleted. More...
 

Private Member Functions

void clean_unsafe ()
 

Private Attributes

std::mutex m_cleanup_mutex
 
std::unordered_set< ICollectable * > m_live_collectables
 
std::vector< ICollectable * > m_phantom_collectables
 

Detailed Description

When a Polyglot wrapper for a C++ object is created, a collectable instance is created to be passed to the Polyglot object (Java).

The memory associated to the collectable must be released when it is no longer needed in the Java side.

Each collectable will be registered here and marked to be deleted under the following scenarios:

  • When the Java Garbage Collector marks the object as a phantom reference.
  • When the Java context is being finalized

The memory is released after calling clean() method.

Constructor & Destructor Documentation

◆ Collectable_registry() [1/3]

shcore::polyglot::Collectable_registry::Collectable_registry ( )
default

◆ Collectable_registry() [2/3]

shcore::polyglot::Collectable_registry::Collectable_registry ( const Collectable_registry )
delete

◆ Collectable_registry() [3/3]

shcore::polyglot::Collectable_registry::Collectable_registry ( Collectable_registry &&  )
delete

◆ ~Collectable_registry()

shcore::polyglot::Collectable_registry::~Collectable_registry ( )

Member Function Documentation

◆ add()

void shcore::polyglot::Collectable_registry::add ( ICollectable target)

◆ clean()

void shcore::polyglot::Collectable_registry::clean ( )

Deletes all collectables which were marked as to be deleted.

◆ clean_unsafe()

void shcore::polyglot::Collectable_registry::clean_unsafe ( )
private

◆ operator=() [1/2]

Collectable_registry & shcore::polyglot::Collectable_registry::operator= ( Collectable_registry &&  )
delete

◆ operator=() [2/2]

Collectable_registry & shcore::polyglot::Collectable_registry::operator= ( const Collectable_registry )
delete

◆ remove()

void shcore::polyglot::Collectable_registry::remove ( ICollectable target)

Member Data Documentation

◆ m_cleanup_mutex

std::mutex shcore::polyglot::Collectable_registry::m_cleanup_mutex
private

◆ m_live_collectables

std::unordered_set<ICollectable *> shcore::polyglot::Collectable_registry::m_live_collectables
private

◆ m_phantom_collectables

std::vector<ICollectable *> shcore::polyglot::Collectable_registry::m_phantom_collectables
private

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