10#ifndef ATERMPP_DETAIL_ATERM_POOL_H
11#define ATERMPP_DETAIL_ATERM_POOL_H
31template<std::
size_t N>
106 inline std::size_t
capacity() const noexcept;
109 inline
std::
size_t size() const;
157 template<
class ...Terms>
163 template<
typename ForwardIterator>
166 ForwardIterator begin,
167 ForwardIterator end);
172 template<
typename InputIterator,
typename ATermConverter>
175 ATermConverter convert_to_aterm,
227 : m_pool(
pool), m_mark_function(mark_function), m_print_function(print_function), m_protection_set_size_function(protection_set_size_function)
The aterm_core base class that provides protection of the underlying shared terms.
The interface for the term library. Provides the storage of of all classes of terms.
const function_symbol & as_int() noexcept
void created_term(bool allow_collect, mcrl2::utilities::shared_mutex &mutex)
Triggers garbage collection and resizing when conditions are met.
bool create_appl(aterm &term, const function_symbol &sym, const Terms &... arguments)
Creates a function application with the given function symbol and arguments.
std::atomic< bool > m_enable_garbage_collection
std::atomic< long > m_count_until_resize
void remove_thread_aterm_pool(thread_aterm_pool_interface &pool)
Remove thread specific aterm pool.
std::vector< thread_aterm_pool_interface * > m_thread_pools
The set of local aterm pools.
bool create_int(aterm &term, std::size_t val)
Creates a integral term with the given value.
function_symbol_pool m_function_symbol_pool
Storage for the function symbols.
void collect_impl(mcrl2::utilities::shared_mutex &mutex)
Collect garbage on all storages.
arbitrary_function_application_storage m_appl_dynamic_storage
Storage for term_appl with a dynamic number of arguments larger than 7.
const function_symbol & as_empty_list() noexcept
function_symbol create_function_symbol(const std::string &name, const std::size_t arity, const bool check_for_registered_functions=false)
Creates a function symbol pair (name, arity).
const function_symbol & as_list() noexcept
aterm_core m_empty_list
Represents an empty list.
mcrl2::utilities::shared_mutex & shared_mutex()
void print_performance_statistics() const
Prints various performance statistics for the term pool.
std::atomic< long > m_count_until_collection
Track the number of terms destroyed and reduce the freelist.
void register_thread_aterm_pool(thread_aterm_pool_interface &pool)
Register a thread specific aterm pool.
bool create_term(aterm &term, const function_symbol &sym)
Creates a term with the given function symbol.
std::size_t protection_set_size() const
void collect(mcrl2::utilities::shared_mutex &mutex)
Force garbage collection on all storages.
bool create_appl_dynamic(aterm &term, const function_symbol &sym, ForwardIterator begin, ForwardIterator end)
Creates a function application with the given function symbol and the arguments as provided by the gi...
aterm & empty_list() noexcept
mcrl2::utilities::shared_mutex m_shared_mutex
Garbage collection is enabled.
void add_deletion_hook(function_symbol sym, term_callback callback)
Add a callback that is triggered whenever a term with the given function symbol is destroyed.
function_symbol_pool & get_symbol_pool()
std::tuple< term_storage, function_application_storage< 1 >, function_application_storage< 2 >, function_application_storage< 3 >, function_application_storage< 4 >, function_application_storage< 5 >, function_application_storage< 6 >, function_application_storage< 7 > > m_appl_storage
Storage for function applications with a fixed number of arguments.
integer_term_storage m_int_storage
Storage for integral terms.
void resize_if_needed(mcrl2::utilities::shared_mutex &shared)
Resizes all storages if necessary.
void enable_garbage_collection(bool enable)
Enable garbage collection when passing true and disable otherwise.
std::size_t capacity() const noexcept
The number of terms that can be stored without resizing.
This class stores a set of function symbols.
const function_symbol & as_int() noexcept
const function_symbol & as_empty_list() noexcept
const function_symbol & as_list() noexcept
A thread specific aterm pool that provides a local interface to the global term pool....
void mark()
Mark the terms created by this thread to prevent them being garbage collected.
std::function< void()> m_mark_function
std::function< void()> m_print_function
std::size_t protection_set_size() const
thread_aterm_pool_interface(aterm_pool &pool, std::function< void()> mark_function, std::function< void()> print_function, std::function< std::size_t()> protection_set_size_function)
void print_local_performance_statistics() const
Print performance statistics for data stored for this thread.
std::function< std::size_t()> m_protection_set_size_function
~thread_aterm_pool_interface()
This is a thread's specific access to the global aterm pool which ensures that garbage collection and...
This is simply an exclusive lock based on the standard library with the ability to perform no locks w...
Inherit from this class to prevent it from being copyable.
static constexpr bool EnableGarbageCollection
Enable garbage collection.
aterm_pool_storage< _aterm, aterm_hasher_finite< 0 >, aterm_equals_finite< 0 >, 0 > term_storage
constexpr std::size_t DynamicNumberOfArguments
Indicates that the number of arguments is not known at compile time.
The main namespace for the aterm++ library.
void(* term_callback)(const aterm &)
Returns true iff first and second are value-equivalent.
Computes the hash of the given term.
Computes the hash of the given term.