mCRL2
Loading...
Searching...
No Matches
atermpp::detail::thread_aterm_pool Class Referencefinal

This is a thread's specific access to the global aterm pool which ensures that garbage collection and hash table resizing can proceed. More...

#include <thread_aterm_pool.h>

Inheritance diagram for atermpp::detail::thread_aterm_pool:
mcrl2::utilities::noncopyable

Public Member Functions

 thread_aterm_pool (aterm_pool &global_pool)
 
 ~thread_aterm_pool ()
 
function_symbol create_function_symbol (const std::string &name, std::size_t arity, bool check_for_registered_functions=false)
 
function_symbol create_function_symbol (std::string &&name, std::size_t arity, bool check_for_registered_functions=false)
 
void create_int (aterm &term, std::size_t val)
 
void create_term (aterm &term, const function_symbol &sym)
 
template<class ... Terms>
void create_appl (aterm &term, const function_symbol &sym, const Terms &... arguments)
 
template<class Term , class INDEX_TYPE , class ... Terms>
void create_appl_index (aterm &term, const function_symbol &sym, const Terms &... arguments)
 
template<typename ForwardIterator >
void create_appl_dynamic (aterm &term, const function_symbol &sym, ForwardIterator begin, ForwardIterator end)
 
template<typename InputIterator , typename ATermConverter >
void create_appl_dynamic (aterm &term, const function_symbol &sym, ATermConverter convert_to_aterm, InputIterator begin, InputIterator end)
 
void register_variable (aterm_core *variable)
 Consider the given variable when marking underlying terms.
 
void deregister_variable (aterm_core *variable)
 Removes the given variable from the active variables.
 
void register_container (aterm_container *variable)
 Consider the given container when marking underlying terms.
 
void deregister_container (aterm_container *variable)
 Removes the given container from the active variables.
 
void absorb (mcrl2::utilities::hashtable< aterm_core * > &variables, mcrl2::utilities::hashtable< aterm_container * > &containers)
 Transfers the surviving variables and containers of a pool that is being destroyed into this pool.
 
void mark ()
 
void print_local_performance_statistics () const
 
std::size_t protection_set_size () const
 
mcrl2::utilities::shared_guard lock_shared ()
 Acquire a shared lock on this thread aterm pool.
 
mcrl2::utilities::lock_guard lock ()
 Acquire an exclusive lock.
 
bool is_shared_locked ()
 Returns true iff we are in a shared section.
 
mcrl2::utilities::shared_mutexshared_mutex ()
 Provides access to the underlying shared mutex.
 
void collect ()
 Triggers a global garbage collection.
 
bool resize_is_needed ()
 
void resize ()
 Resizes the global hash tables when needed.
 
template<typename InputIterator >
void create_appl_dynamic (aterm &term, const function_symbol &sym, InputIterator begin, InputIterator end)
 
- Public Member Functions inherited from mcrl2::utilities::noncopyable
 noncopyable ()=default
 
 ~noncopyable ()=default
 
 noncopyable (noncopyable &&)=default
 
noncopyableoperator= (noncopyable &&)=default
 
 noncopyable (const noncopyable &)=delete
 
noncopyableoperator= (const noncopyable &)=delete
 

Private Attributes

aterm_poolm_pool
 
mcrl2::utilities::shared_mutex m_shared_mutex
 Keeps track of pointers to all existing aterm variables and containers.
 
mcrl2::utilities::hashtable< aterm_core * > * m_variables
 
mcrl2::utilities::hashtable< detail::aterm_container * > * m_containers
 
std::size_t m_variable_insertions = 0
 
std::size_t m_container_insertions = 0
 
std::stack< std::reference_wrapper< _aterm > > m_todo
 A reusable todo stack.
 
long m_count_until_check
 
bool m_is_main_thread = false
 
thread_aterm_pool_interface m_thread_interface
 The registered thread aterm pool.
 

Detailed Description

This is a thread's specific access to the global aterm pool which ensures that garbage collection and hash table resizing can proceed.

Definition at line 34 of file thread_aterm_pool.h.

Constructor & Destructor Documentation

◆ thread_aterm_pool()

atermpp::detail::thread_aterm_pool::thread_aterm_pool ( aterm_pool global_pool)
inline

Identify the first constructor call as the main thread.

Definition at line 37 of file thread_aterm_pool.h.

◆ ~thread_aterm_pool()

atermpp::detail::thread_aterm_pool::~thread_aterm_pool ( )
inline

Definition at line 57 of file thread_aterm_pool.h.

Member Function Documentation

◆ absorb()

void atermpp::detail::thread_aterm_pool::absorb ( mcrl2::utilities::hashtable< aterm_core * > &  variables,
mcrl2::utilities::hashtable< aterm_container * > &  containers 
)
inline

Transfers the surviving variables and containers of a pool that is being destroyed into this pool.

Takes no lock itself; the caller must already hold its own exclusive lock (see ~thread_aterm_pool()).

Definition at line 175 of file thread_aterm_pool_implementation.h.

◆ collect()

void atermpp::detail::thread_aterm_pool::collect ( )
inline

Triggers a global garbage collection.

Definition at line 165 of file thread_aterm_pool.h.

◆ create_appl()

template<class ... Terms>
void atermpp::detail::thread_aterm_pool::create_appl ( aterm term,
const function_symbol sym,
const Terms &...  arguments 
)
inline

threadsafe

Definition at line 55 of file thread_aterm_pool_implementation.h.

◆ create_appl_dynamic() [1/3]

template<typename InputIterator , typename ATermConverter >
void atermpp::detail::thread_aterm_pool::create_appl_dynamic ( aterm term,
const function_symbol sym,
ATermConverter  convert_to_aterm,
InputIterator  begin,
InputIterator  end 
)
inline
Thread safety
This function is thread-safe.

Definition at line 114 of file thread_aterm_pool_implementation.h.

◆ create_appl_dynamic() [2/3]

template<typename ForwardIterator >
void atermpp::detail::thread_aterm_pool::create_appl_dynamic ( aterm term,
const function_symbol sym,
ForwardIterator  begin,
ForwardIterator  end 
)
inline

threadsafe

◆ create_appl_dynamic() [3/3]

template<typename InputIterator >
void atermpp::detail::thread_aterm_pool::create_appl_dynamic ( aterm term,
const function_symbol sym,
InputIterator  begin,
InputIterator  end 
)

Definition at line 101 of file thread_aterm_pool_implementation.h.

◆ create_appl_index()

template<class Term , class INDEX_TYPE , class ... Terms>
void atermpp::detail::thread_aterm_pool::create_appl_index ( aterm term,
const function_symbol sym,
const Terms &...  arguments 
)
inline

threadsafe

Definition at line 65 of file thread_aterm_pool_implementation.h.

◆ create_function_symbol() [1/2]

function_symbol atermpp::detail::thread_aterm_pool::create_function_symbol ( const std::string &  name,
std::size_t  arity,
bool  check_for_registered_functions = false 
)
inline

threadsafe

Definition at line 30 of file thread_aterm_pool_implementation.h.

◆ create_function_symbol() [2/2]

function_symbol atermpp::detail::thread_aterm_pool::create_function_symbol ( std::string &&  name,
std::size_t  arity,
bool  check_for_registered_functions = false 
)
inline

threadsafe

Definition at line 23 of file thread_aterm_pool_implementation.h.

◆ create_int()

void atermpp::detail::thread_aterm_pool::create_int ( aterm term,
std::size_t  val 
)
inline

threadsafe

Definition at line 36 of file thread_aterm_pool_implementation.h.

◆ create_term()

void atermpp::detail::thread_aterm_pool::create_term ( aterm term,
const function_symbol sym 
)
inline

threadsafe

Definition at line 45 of file thread_aterm_pool_implementation.h.

◆ deregister_container()

void atermpp::detail::thread_aterm_pool::deregister_container ( aterm_container variable)
inline

Removes the given container from the active variables.

Definition at line 169 of file thread_aterm_pool_implementation.h.

◆ deregister_variable()

void atermpp::detail::thread_aterm_pool::deregister_variable ( aterm_core variable)
inline

Removes the given variable from the active variables.

Definition at line 146 of file thread_aterm_pool_implementation.h.

◆ is_shared_locked()

bool atermpp::detail::thread_aterm_pool::is_shared_locked ( )
inline

Returns true iff we are in a shared section.

Definition at line 159 of file thread_aterm_pool.h.

◆ lock()

mcrl2::utilities::lock_guard atermpp::detail::thread_aterm_pool::lock ( )
inline

Acquire an exclusive lock.

Definition at line 156 of file thread_aterm_pool.h.

◆ lock_shared()

mcrl2::utilities::shared_guard atermpp::detail::thread_aterm_pool::lock_shared ( )
inline

Acquire a shared lock on this thread aterm pool.

Definition at line 153 of file thread_aterm_pool.h.

◆ mark()

void atermpp::detail::thread_aterm_pool::mark ( )
inline

Definition at line 205 of file thread_aterm_pool_implementation.h.

◆ print_local_performance_statistics()

void atermpp::detail::thread_aterm_pool::print_local_performance_statistics ( ) const
inline

Definition at line 231 of file thread_aterm_pool_implementation.h.

◆ protection_set_size()

std::size_t atermpp::detail::thread_aterm_pool::protection_set_size ( ) const
inline

Definition at line 240 of file thread_aterm_pool_implementation.h.

◆ register_container()

void atermpp::detail::thread_aterm_pool::register_container ( aterm_container variable)
inline

Consider the given container when marking underlying terms.

Definition at line 152 of file thread_aterm_pool_implementation.h.

◆ register_variable()

void atermpp::detail::thread_aterm_pool::register_variable ( aterm_core variable)
inline

Consider the given variable when marking underlying terms.

Definition at line 127 of file thread_aterm_pool_implementation.h.

◆ resize()

void atermpp::detail::thread_aterm_pool::resize ( )
inline

Resizes the global hash tables when needed.

Definition at line 173 of file thread_aterm_pool.h.

◆ resize_is_needed()

bool atermpp::detail::thread_aterm_pool::resize_is_needed ( )
inline

Returns true iff one of the global hash tables has to be resized.

Only takes a shared lock, as opposed to resize() below, so it can be used to avoid suspending all other threads when no resize is needed.

Definition at line 170 of file thread_aterm_pool.h.

◆ shared_mutex()

mcrl2::utilities::shared_mutex & atermpp::detail::thread_aterm_pool::shared_mutex ( )
inline

Provides access to the underlying shared mutex.

Definition at line 162 of file thread_aterm_pool.h.

Member Data Documentation

◆ m_container_insertions

std::size_t atermpp::detail::thread_aterm_pool::m_container_insertions = 0
private

Definition at line 184 of file thread_aterm_pool.h.

◆ m_containers

mcrl2::utilities::hashtable<detail::aterm_container*>* atermpp::detail::thread_aterm_pool::m_containers
private

Definition at line 181 of file thread_aterm_pool.h.

◆ m_count_until_check

long atermpp::detail::thread_aterm_pool::m_count_until_check
private

Definition at line 187 of file thread_aterm_pool.h.

◆ m_is_main_thread

bool atermpp::detail::thread_aterm_pool::m_is_main_thread = false
private

Definition at line 190 of file thread_aterm_pool.h.

◆ m_pool

aterm_pool& atermpp::detail::thread_aterm_pool::m_pool
private

Definition at line 176 of file thread_aterm_pool.h.

◆ m_shared_mutex

mcrl2::utilities::shared_mutex atermpp::detail::thread_aterm_pool::m_shared_mutex
private

Keeps track of pointers to all existing aterm variables and containers.

Definition at line 179 of file thread_aterm_pool.h.

◆ m_thread_interface

thread_aterm_pool_interface atermpp::detail::thread_aterm_pool::m_thread_interface
private

The registered thread aterm pool.

Definition at line 193 of file thread_aterm_pool.h.

◆ m_todo

std::stack<std::reference_wrapper<_aterm> > atermpp::detail::thread_aterm_pool::m_todo
private

A reusable todo stack.

Definition at line 185 of file thread_aterm_pool.h.

◆ m_variable_insertions

std::size_t atermpp::detail::thread_aterm_pool::m_variable_insertions = 0
private

Definition at line 183 of file thread_aterm_pool.h.

◆ m_variables

mcrl2::utilities::hashtable<aterm_core*>* atermpp::detail::thread_aterm_pool::m_variables
private

Definition at line 180 of file thread_aterm_pool.h.


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