mCRL2
Loading...
Searching...
No Matches
aterm_pool.h
Go to the documentation of this file.
1// Author(s): Jeroen Keiren, Maurice Laveaux.
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9
10#ifndef ATERMPP_DETAIL_ATERM_POOL_H
11#define ATERMPP_DETAIL_ATERM_POOL_H
12
13#include "mcrl2/atermpp/detail/aterm_pool_storage.h"
14#include "mcrl2/atermpp/detail/function_symbol_pool.h"
15
16#include "mcrl2/utilities/shared_mutex.h"
17
18#include <atomic>
19#include <cassert>
20
21
22namespace atermpp::detail
23{
24
25/// Define several specializations of the term pool storage objects.
32
33template<std::size_t N>
35
36// There are some annoying circular dependencies between a aterm_pool and the contained thread_aterm_pool_interfaces
37class aterm_pool;
38
39/// \brief A thread specific aterm pool that provides a local interface to the global term pool.
40/// Ensures that terms created by this thread are protected during garbage collection.
41class thread_aterm_pool_interface final
42{
43public:
44 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);
46
47 /// \brief Mark the terms created by this thread to prevent them being garbage collected.
48 void mark()
49 {
50 m_mark_function();
51 }
52
53 /// \brief Print performance statistics for data stored for this thread.
55 {
56 m_print_function();
57 }
58
59 /// \returns The total number of terms residing in the pool.
61 {
62 return m_protection_set_size_function();
63 }
64
65 // Prematurely unregister the thread_aterm_pool_interface.
66 void unregister();
67
68private:
73 bool m_registered = true;
74};
75
77
78/// \brief The interface for the term library. Provides the storage of
79/// of all classes of terms.
80/// \details Internally uses different storage objects to store specific
81/// classes of terms. For a given term creation it can decide what
82/// storage to use at run-time using its function symbol.
84{
85public:
86 inline aterm_pool();
87 inline ~aterm_pool();
88
89 friend class thread_aterm_pool;
90
91 /// \brief Creates a function symbol pair (name, arity).
92 /// \see function_symbol_pool.
93 inline
95
96 /// \brief Creates a function symbol pair (name, arity).
97 /// \see function_symbol_pool.
98 inline
100
101 /// \brief Register a thread specific aterm pool.
102 /// \details threadsafe
103 inline void register_thread_aterm_pool(thread_aterm_pool_interface& pool);
104
105 /// \brief Remove thread specific aterm pool.
106 /// \details threadsafe
107 inline void remove_thread_aterm_pool(thread_aterm_pool_interface& pool);
108
109 /// \brief The number of terms that can be stored without resizing.
110 inline std::size_t capacity() const noexcept;
111
112 /// \returns The total number of terms residing in the pool.
113 inline std::size_t size() const;
114
115 /// \brief Prints various performance statistics for the term pool.
116 inline void print_performance_statistics() const;
117
118 /// \returns A global term that indicates the empty list.
119 aterm& empty_list() noexcept { return reinterpret_cast<aterm&>(m_empty_list); } // TODO remove this reinterpret cast by letting m_empty_list become an aterm.
120
121 /// \returns The function symbol used by integral terms.
122 const function_symbol& as_int() noexcept { return m_function_symbol_pool.as_int(); }
123
124 /// \returns The function symbol used by the list constructor.
125 const function_symbol& as_list() noexcept { return m_function_symbol_pool.as_list(); }
126
127 /// \returns The function symbol used by the term indicating the empty list.
128 const function_symbol& as_empty_list() noexcept { return m_function_symbol_pool.as_empty_list(); }
129
130 /// \brief Add a callback that is triggered whenever a term with the given function symbol is destroyed.
131 inline void add_deletion_hook(function_symbol sym, term_callback callback);
132
133 /// \brief Enable garbage collection when passing true and disable otherwise.
134 inline void enable_garbage_collection(bool enable) { m_enable_garbage_collection = enable; };
135
136 /// \brief Postpones automatic garbage collection until resume_garbage_collection has been called as often as this
137 /// function. Explicitly requested garbage collection still takes place.
138 /// \details threadsafe
140 {
141 m_garbage_collection_pauses.fetch_add(1, std::memory_order_relaxed);
142 }
143
144 /// \brief Ends one pause_garbage_collection.
145 /// \details threadsafe
147 {
148 [[maybe_unused]] const std::size_t pauses = m_garbage_collection_pauses.fetch_sub(1, std::memory_order_relaxed);
149 assert(pauses > 0);
150 }
151
152 /// \brief Enable automatic hash table resizing when passing true and disable otherwise.
153 inline void enable_resize(bool enable) { m_enable_resize = enable; };
154
155 inline function_symbol_pool& get_symbol_pool() { return m_function_symbol_pool; }
156
157 // These functions of the aterm pool should be called through a thread_aterm_pool.
158private:
159 /// \brief Force garbage collection on all storages.
160 /// \details threadsafe
161 inline void collect(mcrl2::utilities::shared_mutex& mutex);
162
163 /// \brief Triggers garbage collection and resizing when conditions are met.
164 /// \param allow_collect Actually perform the garbage collection instead of only updating the counters.
165 /// \param mutex The shared mutex that should be used for locking if necessary.
166 /// \details threadsafe
167 inline void created_term(mcrl2::utilities::shared_mutex& mutex, long& count_until_check);
168
169 /// \brief Collect garbage on all storages.
170 /// \details threadsafe
171 inline void collect_impl(mcrl2::utilities::shared_mutex& mutex);
172
173 /// \brief Creates a integral term with the given value.
174 inline bool create_int(aterm& term, std::size_t val);
175
176 /// \brief Creates a term with the given function symbol.
177 inline bool create_term(aterm& term, const function_symbol& sym);
178
179 /// \brief Creates a function application with the given function symbol and arguments.
180 template<class ...Terms>
181 inline bool create_appl(aterm& term, const function_symbol& sym, const Terms&... arguments);
182
183 /// \brief Creates a function application with the given function symbol and the arguments
184 /// as provided by the given iterator. This function assumes that the arity of the
185 /// function symbol is equal to the number of elements in the iterator.
186 template<typename ForwardIterator>
187 bool create_appl_dynamic(aterm& term,
188 const function_symbol& sym,
189 ForwardIterator begin,
190 ForwardIterator end);
191
192 /// \brief Creates a function application with the given function symbol and the arguments
193 /// as provided by the given iterator. This function assumes that the arity of the
194 /// function symbol is equal to the number of elements in the iterator.
195 template<typename InputIterator, typename ATermConverter>
196 bool create_appl_dynamic(aterm& term,
197 const function_symbol& sym,
198 ATermConverter convert_to_aterm,
199 InputIterator begin,
200 InputIterator end);
201
202 /// \brief Resizes all storages if necessary.
203 /// \details This locks the shared mutex in shared mode for thread safety.
204 inline bool resize_is_needed(mcrl2::utilities::shared_mutex& shared) const;
205
206 /// \brief Resizes all storages if necessary.
207 /// \details threadsafe
208 inline void resize_if_needed(mcrl2::utilities::shared_mutex& shared);
209
210 mcrl2::utilities::shared_mutex& shared_mutex() { return m_shared_mutex; }
211
212 /// \returns The total number of term variables residing in the protection sets.
213 inline std::size_t protection_set_size() const;
214
215 /// \brief The set of local aterm pools.
217
218 /// \brief Storage for the function symbols.
220
221 /// \brief Storage for integral terms.
223
224 /// Storage for function applications with a fixed number of arguments.
225 std::tuple<
235
236 /// Storage for term_appl with a dynamic number of arguments larger than 7.
238
239 /// Track the number of terms destroyed and reduce the freelist.
240 std::atomic<long> m_count_until_collection = 0;
241
242 std::atomic<bool> m_enable_garbage_collection = EnableGarbageCollection; /// Garbage collection is enabled.
243
244 /// The number of active pause_garbage_collection calls; automatic garbage collection only takes place when it is 0.
246
247 std::atomic<bool> m_enable_resize = true; /// Automatic hash table resizing is enabled.
248
249 /// All the shared mutexes.
251
252 /// Represents an empty list.
254};
255
256inline
257thread_aterm_pool_interface::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)
259{
261}
262
263inline
264void thread_aterm_pool_interface::unregister()
265{
266 if (m_registered)
267 {
269 m_registered = false;
270 }
271}
272
273inline
274thread_aterm_pool_interface::~thread_aterm_pool_interface()
275{
277}
278
279} // namespace atermpp::detail
280
281
284
285#endif // ATERMPP_DETAIL_ATERM_POOL_H
atermpp::aterm create_nested_function(const std::string &function_name, const std::string &leaf_name, std::size_t number_of_arguments, std::size_t depth)
Create a nested function application f_depth. Where f_0 = c and f_i = f(f_i-1,...,...
atermpp::aterm create_nested_function(const std::string &function_name, const std::string &leaf_name, std::size_t depth)
Create a nested function application f_depth. Where f_0 = c and f_i = f(f_i-1,...,...
void benchmark_threads(std::size_t number_of_threads, F f)
Run the given function f on number_of_threads threads (including the main thread) and report the elap...
The aterm_core base class that provides protection of the underlying shared terms.
Definition aterm_core.h:151
aterm_core & operator=(aterm_core &&other) noexcept
Move assignment operator.
~aterm_core() noexcept
Standard destructor.
aterm_core & operator=(const aterm_core &other) noexcept
Assignment operator.
aterm_core(const aterm_core &other) noexcept
Copy constructor.
aterm_core(aterm_core &&other) noexcept
Move constructor.
aterm_core() noexcept
Default constructor.
aterm_core & assign(const aterm_core &other, detail::thread_aterm_pool &pool) noexcept
Assignment operator, to be used if busy and forbidden flags are explicitly available.
aterm_core & unprotected_assign(const aterm_core &other) noexcept
Assignment operator, to be used when the busy flags do not need to be set.
aterm_core(const detail::_aterm *t) noexcept
Constructor based on an internal term data structure. This is not for public use.
aterm(aterm &&other) noexcept=default
aterm()
Default constructor.
Definition aterm.h:51
aterm & operator=(const aterm &other) noexcept=default
aterm(const aterm &other) noexcept=default
This class has user-declared copy constructor so declare default copy and move operators.
aterm(detail::_term_appl *t)
Constructor.
Definition aterm.h:33
aterm & operator=(aterm &&other) noexcept=default
aterm(const function_symbol &sym, ForwardIterator begin, ForwardIterator end)
Constructor that provides an aterm based on a function symbol and forward iterator providing the argu...
Definition aterm.h:70
This class allocates _aterm_appl objects where the size is based on the arity of the function symbol.
Definition aterm.h:113
T * allocate_args(const function_symbol &symbol, unprotected_aterm_core *)
Allocates space for an _aterm_appl where the arity is given by the function symbol.
Definition aterm.h:143
T * allocate_args(const function_symbol &symbol, ForwardIterator, ForwardIterator)
Allocates space for an _aterm_appl where the arity is given by the function symbol.
Definition aterm.h:134
std::allocator< char > m_packed_allocator
Definition aterm.h:182
static constexpr std::size_t term_appl_size(std::size_t arity)
Definition aterm.h:116
void destroy(T *element)
Specialize destroy for _aterm_appl to only destroy the function symbol. The reference count for the a...
Definition aterm.h:158
constexpr std::size_t capacity() const
Definition aterm.h:177
void deallocate(T *element, std::size_t)
Definition aterm.h:167
constexpr bool has_free_slots() const noexcept
Definition aterm.h:179
constexpr std::size_t consolidate() const noexcept
Definition aterm.h:178
void construct(T *element, const function_symbol &symbol, ForwardIterator begin, ForwardIterator end)
Constructs an _aterm_appl with arguments taken from begin, the arity is given by the function symbol.
Definition aterm.h:152
This class stores a term followed by N arguments. Where N should be equal to the arity of the functio...
Definition aterm.h:34
_aterm_appl(const function_symbol &symbol, Iterator it, Iterator end, bool)
constructs a term application with the given symbol and its arguments from the iterator.
Definition aterm.h:74
_aterm_appl(const function_symbol &sym, const Terms &... arguments)
Constructs a term application with the given symbol and arguments.
Definition aterm.h:39
_aterm_appl(const function_symbol &sym, std::array< unprotected_aterm_core, N > arguments)
Constructs a term application with the given symbol and arguments.
Definition aterm.h:65
std::array< unprotected_aterm_core, N > m_arguments
Definition aterm.h:102
operator _aterm_appl< 1 > &()
Convert any known number of arguments aterm<N> to the default _aterm_appl.
Definition aterm.h:96
_aterm_appl(const function_symbol &sym, Iterator it, Iterator end)
constructs a term application with the given symbol and an iterator where the number of elements is e...
Definition aterm.h:50
const aterm_core & arg(std::size_t index) const
Definition aterm.h:90
This is the class to which an aterm points.
Definition aterm_core.h:48
bool is_marked() const
Check if the term is already marked.
Definition aterm_core.h:73
_aterm(const function_symbol &symbol)
Create a term from a function symbol.
Definition aterm_core.h:51
function_symbol m_function_symbol
Definition aterm_core.h:79
const function_symbol & function() const noexcept
Definition aterm_core.h:55
void mark() const
Mark this term to be garbage collected.
Definition aterm_core.h:61
void unmark() const
Remove the mark from a term.
Definition aterm_core.h:67
Stores the data for a function symbol (name, arity) pair.
const std::string & name() const noexcept
bool operator==(const _function_symbol &f) const noexcept
std::size_t arity() const noexcept
The interface for the term library. Provides the storage of of all classes of terms.
Definition aterm_pool.h:84
const function_symbol & as_int() noexcept
Definition aterm_pool.h:122
void enable_resize(bool enable)
Enable automatic hash table resizing when passing true and disable otherwise.
Definition aterm_pool.h:153
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
Definition aterm_pool.h:242
function_symbol create_function_symbol(const std::string &name, std::size_t arity, bool check_for_registered_functions=false)
Creates a function symbol pair (name, arity).
void resume_garbage_collection()
Ends one pause_garbage_collection.
Definition aterm_pool.h:146
function_symbol create_function_symbol(std::string &&name, std::size_t arity, bool check_for_registered_functions=false)
Creates a function symbol pair (name, arity).
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.
Definition aterm_pool.h:216
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.
Definition aterm_pool.h:219
void collect_impl(mcrl2::utilities::shared_mutex &mutex)
Collect garbage on all storages.
bool resize_is_needed(mcrl2::utilities::shared_mutex &shared) const
Resizes all storages if necessary.
arbitrary_function_application_storage m_appl_dynamic_storage
Storage for term_appl with a dynamic number of arguments larger than 7.
Definition aterm_pool.h:237
const function_symbol & as_empty_list() noexcept
Definition aterm_pool.h:128
const function_symbol & as_list() noexcept
Definition aterm_pool.h:125
aterm_core m_empty_list
Represents an empty list.
Definition aterm_pool.h:253
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.
Definition aterm_pool.h:240
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.
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...
bool create_appl_dynamic(aterm &term, const function_symbol &sym, ATermConverter convert_to_aterm, InputIterator begin, InputIterator end)
Creates a function application with the given function symbol and the arguments as provided by the gi...
aterm & empty_list() noexcept
Definition aterm_pool.h:119
std::atomic< std::size_t > m_garbage_collection_pauses
Garbage collection is enabled.
Definition aterm_pool.h:245
mcrl2::utilities::shared_mutex m_shared_mutex
Automatic hash table resizing is enabled.
Definition aterm_pool.h:250
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()
Definition aterm_pool.h:155
integer_term_storage m_int_storage
Storage for integral terms.
Definition aterm_pool.h:222
std::atomic< bool > m_enable_resize
Definition aterm_pool.h:247
void pause_garbage_collection()
Postpones automatic garbage collection until resume_garbage_collection has been called as often as th...
Definition aterm_pool.h:139
void created_term(mcrl2::utilities::shared_mutex &mutex, long &count_until_check)
Triggers garbage collection and resizing when conditions are met.
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.
Definition aterm_pool.h:134
std::size_t capacity() const noexcept
The number of terms that can be stored without resizing.
This class stores a set of function symbols.
void mark()
Mark the terms created by this thread to prevent them being garbage collected.
Definition aterm_pool.h:48
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)
Definition aterm_pool.h:257
void print_local_performance_statistics() const
Print performance statistics for data stored for this thread.
Definition aterm_pool.h:54
std::function< std::size_t()> m_protection_set_size_function
Definition aterm_pool.h:72
std::stack< std::reference_wrapper< _aterm > > m_todo
A reusable todo stack.
void swap(function_symbol &f) noexcept
Swap this function with its argument.
bool operator!=(const function_symbol &f) const
Inequality test.
function_symbol & operator=(const function_symbol &other) noexcept=default
function_symbol(function_symbol &&other) noexcept=default
bool operator>=(const function_symbol &f) const
Comparison operation.
bool operator==(const function_symbol &f) const
Equality test.
function_symbol(detail::_function_symbol::ref &&f)
Constructor for internal use only.
bool operator<(const function_symbol &f) const
Comparison operation.
function_symbol(const function_symbol &other) noexcept=default
This class has non-trivial destructor so declare default copy and move operators.
void destroy()
Calls the function symbol pool to free our used memory.
function_symbol & operator=(function_symbol &&other) noexcept=default
std::size_t arity() const
Return the arity (number of arguments) of the function symbol (function_symbol).
detail::_function_symbol::ref m_function_symbol
The shared reference to the underlying function symbol.
const std::string & name() const
Return the name of the function_symbol.
bool operator>(const function_symbol &f) const
Comparison operation.
bool operator<=(const function_symbol &f) const
Comparison operation.
Postpones automatic garbage collection while an object of this class exists, for instance while readi...
Definition aterm.h:173
garbage_collection_pause(garbage_collection_pause &&)=delete
garbage_collection_pause & operator=(const garbage_collection_pause &)=delete
garbage_collection_pause(const garbage_collection_pause &)=delete
garbage_collection_pause & operator=(garbage_collection_pause &&)=delete
term_appl_iterator operator++(int)
Postfix increment.
bool operator==(const term_appl_iterator &other) const
Equality of iterators.
term_appl_iterator operator-(ptrdiff_t n) const
Decrease by a constant value.
term_appl_iterator & operator--()
Prefix decrement.
ptrdiff_t operator-(const term_appl_iterator &other) const
The negative distance from this to the other iterator.
term_appl_iterator & operator++()
Prefix increment.
term_appl_iterator & operator-=(difference_type n)
Decrease the iterator with n steps.
const Term & operator[](difference_type n) const
The dereference operator.
term_appl_iterator operator+(ptrdiff_t n) const
Increase by a constant value.
friend term_appl_iterator< Derived > detail::aterm_appl_iterator_cast(term_appl_iterator< Base > a)
term_appl_iterator operator--(int)
Post decrement an iterator.
const Term * operator->() const
Dereference the current iterator.
term_appl_iterator & operator+=(difference_type n)
Increase the iterator with n steps.
const Term & operator*() const
The dereference operator.
term_appl_iterator(const Term *t)
Constructor.
ptrdiff_t distance_to(const term_appl_iterator &other) const
Provide the distance to the other iterator.
A unordered_map class in which aterms can be stored.
An unprotected term does not change the reference count of the shared term when it is copied or moved...
Definition aterm_core.h:34
bool type_is_list() const noexcept
Dynamic check whether the term is an aterm_list.
Definition aterm_core.h:75
void swap(unprotected_aterm_core &t) noexcept
Swaps this term with its argument.
Definition aterm_core.h:120
bool operator==(const unprotected_aterm_core &t) const
Comparison operator.
Definition aterm_core.h:87
unprotected_aterm_core() noexcept
Default constuctor.
Definition aterm_core.h:43
bool type_is_appl() const noexcept
Dynamic check whether the term is an aterm.
Definition aterm_core.h:57
bool defined() const
Returns true if this term is not equal to the term assigned by the default constructor of aterms,...
Definition aterm_core.h:111
friend detail::_aterm * detail::address(const unprotected_aterm_core &t)
const detail::_aterm * m_term
Definition aterm_core.h:38
const function_symbol & function() const
Yields the function symbol in an aterm.
Definition aterm_core.h:129
bool type_is_int() const noexcept
Dynamic check whether the term is an aterm_int.
Definition aterm_core.h:65
unprotected_aterm_core(const detail::_aterm *term) noexcept
Constructor.
Definition aterm_core.h:49
Inherit from this class to prevent it from being copyable.
Definition noncopyable.h:20
noncopyable & operator=(const noncopyable &)=delete
noncopyable & operator=(noncopyable &&)=default
noncopyable(const noncopyable &)=delete
noncopyable(noncopyable &&)=default
Stores a reference count that can be incremented and decremented.
static void count_reference_count_changes()
Increment the number of reference count changes.
std::size_t reference_count() const
Obtain the reference count.
void increment_reference_count() const
Increment the reference count by one.
static std::atomic< std::size_t > & reference_count_changes()
Obtain the number of times that this reference count has changed.
void decrement_reference_count() const
Decrement the reference count by one.
A reference counted reference to a shared_reference_counted object.
bool operator==(const shared_reference< T > &other) const noexcept
Address equality operator.
shared_reference< T > & operator=(shared_reference< T > &&other) noexcept
Move assignment constructor.
bool defined() const
Check whether the shared_reference has a valid reference.
shared_reference() noexcept
The default constructor.
utilities::tagged_pointer< T > m_reference
shared_reference< T > & operator=(const shared_reference< T > &other) noexcept
Copy assignment constructor.
shared_reference(shared_reference< T > &&other) noexcept
Move constructor.
shared_reference(const shared_reference< T > &other) noexcept
Copy constructor.
shared_reference(T *reference) noexcept
Takes ownership of the passed reference, which means that its reference count is incremented.
void swap(shared_reference< T > &other) noexcept
Swaps *this with the other shared reference.
A pointer storage object that uses a least significant bit as a mark. Can be used by objects that are...
bool operator==(const tagged_pointer &other) const
bool operator==(std::nullptr_t) const
void untag() const
Remove the tag.
void swap(tagged_pointer< T > &other) noexcept
void tag() const
Apply a tag to the pointer that can be checked with tagged().
tagged_pointer & operator=(std::nullptr_t)
std::conditional_t< detail::GlobalThreadSafe, detail::atomic_wrapper< T * >, T * > m_pointer
Implements a simple stopwatch that starts on construction.
Definition stopwatch.h:17
static constexpr bool EnableGarbageCollection
Enable garbage collection.
static constexpr bool EnableHashtableMetrics
Enable to print hashtable collision, size and number of buckets.
aterm_pool & g_term_pool()
obtain a reference to the global aterm pool.
void debug_print(std::ostream &o, const _aterm *t, std::size_t d=3)
void make_list_forward(term_list< Term > &result, Iter first, Iter last, ATermConverter convert_to_aterm)
Constructs a list starting from first to last. Each element is converted using the TermConverter.
static constexpr bool EnableCreationMetrics
Enable to obtain the percentage of terms found compared to allocated.
void make_list_forward(term_list< Term > &result, Iter first, Iter last, ATermConverter convert_to_aterm, ATermFilter aterm_filter)
Constructs a list traversing the iterator from first to last, putting the result in place in the vari...
function_symbol g_as_empty_list
term_list< Term > make_list_backward(Iter first, Iter last, ATermConverter convert_to_aterm, ATermFilter aterm_filter)
Constructs a list starting from first to last. The iterators are traversed backwards and each element...
term_list< Term > make_list_forward(Iter first, Iter last, ATermConverter convert_to_aterm)
Constructs a list starting from first to last. Each element is converted using the TermConverter.
function_symbol g_as_list
static constexpr bool EnableGarbageCollectionMetrics
Enable to print garbage collection statistics.
void start_gc_stress_thread()
Spawns a dedicated background thread that continuously triggers garbage collection.
term_list< Term > make_list_backward(Iter first, Iter last, ATermConverter convert_to_aterm)
Constructs a list starting from first to last. The iterators are traversed backwards and each element...
aterm_pool & g_aterm_pool_instance()
A reference to the global term pool storage.
static constexpr bool EnableAggressiveGarbageCollection
Performs garbage collection intensively for testing purposes.
term_list< Term > make_list_forward(Iter first, Iter last, ATermConverter convert_to_aterm, ATermFilter aterm_filter)
Constructs a list starting from first to last. Each element is converted using the TermConverter and ...
function_symbol g_as_int
These function symbols are used to indicate integer, list and empty list terms.
static constexpr bool EnableBlockAllocator
Enable the block allocator for terms.
void make_list_backward(term_list< Term > &result, Iter first, Iter last, ATermConverter convert_to_aterm, ATermFilter aterm_filter)
Construct a list iterating from the last to the first element. Result is put in the variable result.
void make_list_backward(term_list< Term > &result, Iter first, Iter last, ATermConverter convert_to_aterm)
Constructs a list starting from first to last where the result is put in result.
static constexpr bool EnableVariableRegistrationMetrics
Keep track of the number of variables registered.
std::array< std::byte, sizeof(aterm_pool)> g_aterm_pool_storage
Storage for a global term pool that is not initialized.
term_appl_iterator< Derived > aterm_appl_iterator_cast(term_appl_iterator< Base > a)
This function can be used to translate an term_appl_iterator of one sort into another.
static constexpr bool EnableGCStressThread
Spawns a dedicated background thread that continuously triggers garbage collection.
The main namespace for the aterm++ library.
std::string pp(const atermpp::aterm &t)
Transform an aterm to an ascii string.
Definition aterm.h:344
void add_deletion_hook(const function_symbol &, term_callback)
Check for reasonably sized aterm (32 bits, 4 bytes) This check might break on perfectly valid archite...
void make_term_appl(Term &target, const function_symbol &sym, ForwardIterator begin, ForwardIterator end)
Constructor an aterm in a variable based on a function symbol and an forward iterator providing the a...
Definition aterm.h:195
static constexpr bool GlobalThreadSafe
Enables thread safety for the whole toolset.
T * tag(const T *p)
Applies a tag to a pointer.
bool tagged(const T *p)
T * pointer(const detail::atomic_wrapper< T * > &p)
T * pointer(const T *p)
T * tag(const detail::atomic_wrapper< T * > &p)
constexpr bool is_iterable_v
Definition type_traits.h:51
static constexpr bool EnableReferenceCountMetrics
Enable to count the number of reference count changes.
bool tagged(const detail::atomic_wrapper< T * > &p)
constexpr bool is_iterator_v
Definition type_traits.h:54
void swap(atermpp::aterm &t1, atermpp::aterm &t2) noexcept
Swaps two term_applss.
Definition aterm.h:379
void swap(mcrl2::utilities::shared_reference< T > &a, mcrl2::utilities::shared_reference< T > &b) noexcept
void swap(atermpp::unprotected_aterm_core &t1, atermpp::unprotected_aterm_core &t2) noexcept
Swaps two aterms.
Definition aterm.h:366
int main(int argc, char *argv[])
void operator()(Term &result, const Term &t) const
Definition aterm_list.h:35
const Term & operator()(const Term &t) const
Definition aterm_list.h:40
Term & operator()(Term &t) const
Definition aterm_list.h:45
atomic_wrapper & operator=(const atomic_wrapper< T > &other)
atomic_wrapper(const atomic_wrapper< T > &other)
Checks whether condition holds for all types passed as variadic template.
Definition type_traits.h:43
A typetrait that is std::true_type iff std::begin() and std::end() can be called on type T.
Definition type_traits.h:22
A typetrait that is std::true_type iff the given type has the iterator traits.
Definition type_traits.h:38
std::size_t operator()(const atermpp::aterm &t) const
Definition aterm.h:388
std::size_t operator()(const mcrl2::utilities::tagged_pointer< T > &p) const
std::size_t operator()(const std::vector< X > &v) const