mCRL2
Loading...
Searching...
No Matches
aterm_pool.h
Go to the documentation of this file.
1// Author(s): 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
18namespace atermpp
19{
20namespace detail
21{
22
23/// Define several specializations of the term pool storage objects.
26using arbitrary_function_application_storage = aterm_pool_storage<_aterm_appl<1>,
30
31template<std::size_t N>
32using function_application_storage = aterm_pool_storage<_aterm_appl<N>, aterm_hasher_finite<N>, aterm_equals_finite<N>, N>;
33
34// There are some annoying circular dependencies between a aterm_pool and the contained thread_aterm_pool_interfaces
35class aterm_pool;
36
37/// \brief A thread specific aterm pool that provides a local interface to the global term pool.
38/// Ensures that terms created by this thread are protected during garbage collection.
39class thread_aterm_pool_interface final
40{
41public:
42 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);
44
45 /// \brief Mark the terms created by this thread to prevent them being garbage collected.
46 void mark()
47 {
48 m_mark_function();
49 }
50
51 /// \brief Print performance statistics for data stored for this thread.
53 {
54 m_print_function();
55 }
56
57 /// \returns The total number of terms residing in the pool.
58 std::size_t protection_set_size() const
59 {
60 return m_protection_set_size_function();
61 }
62
63 // Prematurely unregister the thread_aterm_pool_interface.
64 void unregister();
65
66private:
68 std::function<void()> m_mark_function;
69 std::function<void()> m_print_function;
71 bool m_registered = true;
72};
73
74class thread_aterm_pool;
75
76/// \brief The interface for the term library. Provides the storage of
77/// of all classes of terms.
78/// \details Internally uses different storage objects to store specific
79/// classes of terms. For a given term creation it can decide what
80/// storage to use at run-time using its function symbol.
81class aterm_pool : public mcrl2::utilities::noncopyable
82{
83public:
84 inline aterm_pool();
85 inline ~aterm_pool();
86
87 friend class thread_aterm_pool;
88
89 /// \brief Creates a function symbol pair (name, arity).
90 /// \see function_symbol_pool.
91 inline function_symbol create_function_symbol(const std::string& name, const std::size_t arity, const bool check_for_registered_functions = false);
92
93 /// \brief Creates a function symbol pair (name, arity).
94 /// \see function_symbol_pool.
95 inline function_symbol create_function_symbol(std::string&& name, const std::size_t arity, const bool check_for_registered_functions = false);
96
97 /// \brief Register a thread specific aterm pool.
98 /// \details threadsafe
99 inline void register_thread_aterm_pool(thread_aterm_pool_interface& pool);
100
101 /// \brief Remove thread specific aterm pool.
102 /// \details threadsafe
103 inline void remove_thread_aterm_pool(thread_aterm_pool_interface& pool);
104
105 /// \brief The number of terms that can be stored without resizing.
106 inline std::size_t capacity() const noexcept;
107
108 /// \returns The total number of terms residing in the pool.
109 inline std::size_t size() const;
110
111 /// \brief Prints various performance statistics for the term pool.
112 inline void print_performance_statistics() const;
113
114 /// \returns A global term that indicates the empty list.
115 aterm& empty_list() noexcept { return reinterpret_cast<aterm&>(m_empty_list); } // TODO remove this reinterpret cast by letting m_empty_list become an aterm.
116
117 /// \returns The function symbol used by integral terms.
118 const function_symbol& as_int() noexcept { return m_function_symbol_pool.as_int(); }
119
120 /// \returns The function symbol used by the list constructor.
121 const function_symbol& as_list() noexcept { return m_function_symbol_pool.as_list(); }
122
123 /// \returns The function symbol used by the term indicating the empty list.
124 const function_symbol& as_empty_list() noexcept { return m_function_symbol_pool.as_empty_list(); }
125
126 /// \brief Add a callback that is triggered whenever a term with the given function symbol is destroyed.
127 inline void add_deletion_hook(function_symbol sym, term_callback callback);
128
129 /// \brief Enable garbage collection when passing true and disable otherwise.
130 inline void enable_garbage_collection(bool enable) { m_enable_garbage_collection = enable; };
131
132 inline function_symbol_pool& get_symbol_pool() { return m_function_symbol_pool; }
133
134 // These functions of the aterm pool should be called through a thread_aterm_pool.
135private:
136 /// \brief Force garbage collection on all storages.
137 /// \details threadsafe
138 inline void collect(mcrl2::utilities::shared_mutex& mutex);
139
140 /// \brief Triggers garbage collection and resizing when conditions are met.
141 /// \param allow_collect Actually perform the garbage collection instead of only updating the counters.
142 /// \param mutex The shared mutex that should be used for locking if necessary.
143 /// \details threadsafe
144 inline void created_term(bool allow_collect, mcrl2::utilities::shared_mutex& mutex);
145
146 /// \brief Collect garbage on all storages.
147 /// \details threadsafe
148 inline void collect_impl(mcrl2::utilities::shared_mutex& mutex);
149
150 /// \brief Creates a integral term with the given value.
151 inline bool create_int(aterm& term, std::size_t val);
152
153 /// \brief Creates a term with the given function symbol.
154 inline bool create_term(aterm& term, const function_symbol& sym);
155
156 /// \brief Creates a function application with the given function symbol and arguments.
157 template<class ...Terms>
158 inline bool create_appl(aterm& term, const function_symbol& sym, const Terms&... arguments);
159
160 /// \brief Creates a function application with the given function symbol and the arguments
161 /// as provided by the given iterator. This function assumes that the arity of the
162 /// function symbol is equal to the number of elements in the iterator.
163 template<typename ForwardIterator>
164 bool create_appl_dynamic(aterm& term,
165 const function_symbol& sym,
166 ForwardIterator begin,
167 ForwardIterator end);
168
169 /// \brief Creates a function application with the given function symbol and the arguments
170 /// as provided by the given iterator. This function assumes that the arity of the
171 /// function symbol is equal to the number of elements in the iterator.
172 template<typename InputIterator, typename ATermConverter>
173 bool create_appl_dynamic(aterm& term,
174 const function_symbol& sym,
175 ATermConverter convert_to_aterm,
176 InputIterator begin,
177 InputIterator end);
178
179 /// \brief Resizes all storages if necessary.
180 /// \details threadsafe
181 inline void resize_if_needed(mcrl2::utilities::shared_mutex& shared);
182
183 mcrl2::utilities::shared_mutex& shared_mutex() { return m_shared_mutex; }
184
185 /// \returns The total number of term variables residing in the protection sets.
186 inline std::size_t protection_set_size() const;
187
188 /// \brief The set of local aterm pools.
190
191 /// \brief Storage for the function symbols.
193
194 /// \brief Storage for integral terms.
195 integer_term_storage m_int_storage;
196
197 /// Storage for function applications with a fixed number of arguments.
198 std::tuple<
208
209 /// Storage for term_appl with a dynamic number of arguments larger than 7.
210 arbitrary_function_application_storage m_appl_dynamic_storage;
211
212 /// Track the number of terms destroyed and reduce the freelist.
213 std::atomic<long> m_count_until_collection = 0;
214 std::atomic<long> m_count_until_resize = 0;
215
216 std::atomic<bool> m_enable_garbage_collection = EnableGarbageCollection; /// Garbage collection is enabled.
217
218 /// All the shared mutexes.
220
221 /// Represents an empty list.
223};
224
225inline
226thread_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)
228{
230}
231
232inline
233void thread_aterm_pool_interface::unregister()
234{
235 if (m_registered)
236 {
238 m_registered = false;
239 }
240}
241
242inline
243thread_aterm_pool_interface::~thread_aterm_pool_interface()
244{
246}
247
248} // namespace detail
249} // namespace atermpp
250
253
254#endif // ATERMPP_DETAIL_ATERM_POOL_H
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,...,...
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,...,...
void benchmark_threads(std::size_t number_of_threads, F f)
The aterm_core base class that provides protection of the underlying shared terms.
Definition aterm_core.h:182
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(const function_symbol &sym, InputIterator begin, InputIterator end, TermConverter converter)
Definition aterm.h:116
const_iterator end() const
Returns a const_iterator pointing past the last argument.
Definition aterm.h:172
aterm(const function_symbol &symbol, const Terms &...arguments)
Constructor for n-arity function application.
Definition aterm.h:137
const aterm & operator[](const size_type i) const
Returns the i-th argument.
Definition aterm.h:187
aterm()
Default constructor.
Definition aterm.h:48
const_iterator begin() const
Returns an iterator pointing to the first argument.
Definition aterm.h:165
aterm(const function_symbol &sym, InputIterator begin, InputIterator end)
Constructor that provides an aterm based on a function symbol and an input iterator providing the arg...
Definition aterm.h:96
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:75
aterm & operator=(const aterm &other) noexcept=default
const function_symbol & function() const
Returns the function symbol belonging to an aterm.
Definition aterm.h:144
std::size_t size_type
An unsigned integral type.
Definition aterm.h:36
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:30
ptrdiff_t difference_type
A signed integral type.
Definition aterm.h:39
bool empty() const
Returns true if the term has no arguments.
Definition aterm.h:158
aterm & operator=(aterm &&other) noexcept=default
aterm(const function_symbol &sym)
Constructor.
Definition aterm.h:128
term_appl_iterator< aterm > iterator
Iterator used to iterate through an term_appl.
Definition aterm.h:42
size_type size() const
Returns the number of arguments of this term.
Definition aterm.h:151
term_appl_iterator< aterm > const_iterator
Const iterator used to iterate through an term_appl.
Definition aterm.h:45
constexpr size_type max_size() const
Returns the largest possible number of arguments.
Definition aterm.h:179
This class allocates _aterm_appl objects where the size is based on the arity of the function symbol.
Definition aterm.h:120
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:150
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:141
std::allocator< char > m_packed_allocator
Definition aterm.h:189
static constexpr std::size_t term_appl_size(std::size_t arity)
Definition aterm.h:123
void destroy(T *element)
Specialize destroy for _aterm_appl to only destroy the function symbol. The reference count for the a...
Definition aterm.h:165
constexpr std::size_t capacity() const
Definition aterm.h:184
void deallocate(T *element, std::size_t)
Definition aterm.h:174
constexpr bool has_free_slots() const noexcept
Definition aterm.h:186
constexpr std::size_t consolidate() const noexcept
Definition aterm.h:185
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:159
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 &sym, const Terms &...arguments)
Constructs a term application with the given symbol and arguments.
Definition aterm.h:41
_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:79
_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:69
std::array< unprotected_aterm_core, N > m_arguments
Definition aterm.h:109
operator _aterm_appl< 1 > &()
Convert any known number of arguments aterm<N> to the default _aterm_appl.
Definition aterm.h:103
_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:52
const aterm_core & arg(std::size_t index) const
Definition aterm.h:97
The underlying integer term that actually carries the integer data.
Definition aterm_int.h:22
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
This class provides for all types of term storage. It also provides garbage collection via its mark a...
The interface for the term library. Provides the storage of of all classes of terms.
Definition aterm_pool.h:82
const function_symbol & as_int() noexcept
Definition aterm_pool.h:118
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
Definition aterm_pool.h:216
std::atomic< long > m_count_until_resize
Definition aterm_pool.h:214
function_symbol create_function_symbol(std::string &&name, const std::size_t arity, const 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:189
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:192
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.
Definition aterm_pool.h:210
const function_symbol & as_empty_list() noexcept
Definition aterm_pool.h:124
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
Definition aterm_pool.h:121
aterm_core m_empty_list
Represents an empty list.
Definition aterm_pool.h:222
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:213
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:115
mcrl2::utilities::shared_mutex m_shared_mutex
Garbage collection is enabled.
Definition aterm_pool.h:219
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:132
integer_term_storage m_int_storage
Storage for integral terms.
Definition aterm_pool.h:195
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:130
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:46
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:226
void print_local_performance_statistics() const
Print performance statistics for data stored for this thread.
Definition aterm_pool.h:52
std::function< std::size_t()> m_protection_set_size_function
Definition aterm_pool.h:70
void create_term(aterm &term, const function_symbol &sym)
Generates unique function symbols with a given prefix.
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.
void swap(function_symbol &f)
Swap this function with its argument.
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.
term_appl_iterator operator++(int)
Postfix increment.
bool operator==(const term_appl_iterator &other) const
Equality of iterators.
bool operator<(const term_appl_iterator &other) const
Comparison of iterators.
term_appl_iterator(const term_appl_iterator &other)
The copy constructor.
bool operator>=(const term_appl_iterator &other) const
Comparison of iterators.
term_appl_iterator operator-(ptrdiff_t n) const
Decrease by a constant value.
term_appl_iterator & operator=(const term_appl_iterator &other)
The assignment operator.
term_appl_iterator & operator--()
Prefix decrement.
ptrdiff_t operator-(const term_appl_iterator &other) const
The negative distance from this to the other iterator.
std::random_access_iterator_tag iterator_category
bool operator<=(const term_appl_iterator &other) const
Comparison of iterators.
friend term_appl_iterator< Derived > detail::aterm_appl_iterator_cast(term_appl_iterator< Base > a, typename std::enable_if< std::is_base_of< aterm, Base >::value &&std::is_base_of< aterm, Derived >::value >::type *)
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.
bool operator!=(const term_appl_iterator &other) const
Inequality of iterators.
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.
bool operator>(const term_appl_iterator &other) const
Comparison of iterators.
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 list of aterm objects.
Definition aterm_list.h:24
An unprotected term does not change the reference count of the shared term when it is copied or moved...
Definition aterm_core.h:32
bool operator<=(const unprotected_aterm_core &t) const
Comparison operator for two unprotected aterms.
Definition aterm_core.h:122
bool operator>=(const unprotected_aterm_core &t) const
Comparison operator for two unprotected aterms.
Definition aterm_core.h:131
bool type_is_list() const noexcept
Dynamic check whether the term is an aterm_list.
Definition aterm_core.h:72
void swap(unprotected_aterm_core &t) noexcept
Swaps this term with its argument.
Definition aterm_core.h:152
bool operator>(const unprotected_aterm_core &t) const
Comparison operator for two unprotected aterms.
Definition aterm_core.h:113
bool operator<(const unprotected_aterm_core &t) const
Comparison operator for two unprotected aterms.
Definition aterm_core.h:104
bool operator==(const unprotected_aterm_core &t) const
Comparison operator.
Definition aterm_core.h:83
unprotected_aterm_core() noexcept
Default constuctor.
Definition aterm_core.h:41
bool type_is_appl() const noexcept
Dynamic check whether the term is an aterm.
Definition aterm_core.h:55
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:143
friend detail::_aterm * detail::address(const unprotected_aterm_core &t)
const detail::_aterm * m_term
Definition aterm_core.h:36
bool operator!=(const unprotected_aterm_core &t) const
Inequality operator on two unprotected aterms.
Definition aterm_core.h:92
const function_symbol & function() const
Yields the function symbol in an aterm.
Definition aterm_core.h:161
bool type_is_int() const noexcept
Dynamic check whether the term is an aterm_int.
Definition aterm_core.h:63
unprotected_aterm_core(const detail::_aterm *term) noexcept
Constructor.
Definition aterm_core.h:47
Inherit from this class to prevent it from being copyable.
Definition noncopyable.h:21
noncopyable & operator=(const noncopyable &)=delete
noncopyable(const noncopyable &)=delete
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
bool operator>=(const shared_reference &other) const noexcept
shared_reference< T > & operator=(shared_reference< T > &&other) noexcept
Move assignment constructor.
bool defined() const
Check whether the shared_reference has a valid reference.
bool operator>(const shared_reference< T > &other) const noexcept
shared_reference() noexcept
The default constructor.
void swap(shared_reference< T > &other)
Swaps *this with the other shared reference.
utilities::tagged_pointer< T > m_reference
shared_reference< T > & operator=(const shared_reference< T > &other) noexcept
Copy assignment constructor.
bool operator!=(const shared_reference< T > &other) const noexcept
bool operator<=(const shared_reference< T > &other) const noexcept
shared_reference(shared_reference< T > &&other) noexcept
Move constructor.
shared_reference(const shared_reference< T > &other) noexcept
Copy constructor.
bool operator<(const shared_reference< T > &other) const noexcept
shared_reference(T *reference) noexcept
Takes ownership of the passed reference, which means that its reference count is incremented.
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>(const tagged_pointer &other) const noexcept
bool operator>=(const tagged_pointer &other) const noexcept
bool operator==(std::nullptr_t) const
void swap(tagged_pointer< T > &other)
void untag() const
Remove the tag.
bool operator<(const tagged_pointer &other) const noexcept
void tag() const
Apply a tag to the pointer that can be checked with tagged().
bool operator!=(std::nullptr_t) const
bool operator<=(const tagged_pointer &other) const noexcept
bool operator!=(const tagged_pointer &other) const
std::conditional_t< detail::GlobalThreadSafe, detail::atomic_wrapper< T * >, T * > m_pointer
Implements a simple stopwatch that starts on construction.
Definition stopwatch.h:17
double seconds()
Definition stopwatch.h:37
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.
std::aligned_storage< sizeof(aterm_pool), alignof(aterm_pool)>::type g_aterm_pool_storage
Storage for a global term pool that is not initialized.
aterm 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...
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
static aterm_pool & g_aterm_pool_instance
A reference to the global term pool storage.
aterm 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.
thread_aterm_pool & g_thread_term_pool()
A reference to the thread local term pool storage.
aterm 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_list
static constexpr bool EnableGarbageCollectionMetrics
Enable to print garbage collection statistics.
term_appl_iterator< Derived > aterm_appl_iterator_cast(term_appl_iterator< Base > a, typename std::enable_if< std::is_base_of< aterm, Base >::value &&std::is_base_of< aterm, Derived >::value >::type *=nullptr)
This function can be used to translate an term_appl_iterator of one sort into another.
static constexpr bool EnableAggressiveGarbageCollection
Performs garbage collection intensively for testing purposes.
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.
void debug_print(std::ostream &o, const _aterm *t, const std::size_t d=3)
aterm 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...
constexpr std::size_t DynamicNumberOfArguments
Indicates that the number of arguments is not known at compile time.
Definition aterm_hash.h:78
The main namespace for the aterm++ library.
Definition algorithm.h:21
void make_term_appl(Term &target, const function_symbol &sym, InputIterator begin, InputIterator end, TermConverter converter)
Constructor an aterm in a variable based on a function symbol and an forward iterator providing the a...
Definition aterm.h:268
term_list< aterm > aterm_list
A term_list with elements of type aterm.
Definition aterm_list.h:497
void make_term_appl(Term &target, const function_symbol &sym)
Make an term_appl consisting of a single function symbol.
Definition aterm.h:286
Derived & reference_cast(Derived &t)
A cast from one aterm based type to another, as a reference, allowing to assign to it.
Definition aterm.h:370
void(* term_callback)(const aterm &)
Definition aterm.h:194
std::string pp(const atermpp::aterm &t)
Transform an aterm to an ascii string.
Definition aterm.h:440
void make_term_appl(Term &target, const function_symbol &symbol, const Terms &...arguments)
Make an aterm application for n-arity function application.
Definition aterm.h:301
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:213
void make_term_appl(Term &target, const function_symbol &sym, InputIterator begin, InputIterator end)
Constructor an aterm in a variable based on a function symbol and an input iterator providing the arg...
Definition aterm.h:241
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...
const DerivedCont & container_cast(const Cont< Base > &t, typename std::enable_if_t< is_container< DerivedCont, aterm >::value &&std::is_same_v< Cont< typename DerivedCont::value_type >, DerivedCont > &&!std::is_base_of_v< DerivedCont, Cont< Base > > &&is_convertible< Base, typename DerivedCont::value_type >::value > *=nullptr)
Definition aterm.h:379
void make_term_appl_with_index(aterm &target, const function_symbol &symbol, const Terms &...arguments)
Constructor for n-arity function application with an index.
Definition aterm.h:313
const Derived & vertical_cast(const Base &t, typename std::enable_if< is_convertible< Base, Derived >::value >::type *=nullptr)
A cast form an aterm derived class to a class that inherits in possibly multiple steps from this clas...
Definition aterm.h:399
const Derived & down_cast(const Base &t, typename std::enable_if< is_convertible< Base, Derived >::value &&!std::is_base_of< Derived, Base >::value >::type *=nullptr)
A cheap cast from one aterm based type to another When casting one aterm based type into another,...
Definition aterm.h:337
const DerivedCont & vertical_cast(const Cont< Base > &t, typename std::enable_if_t< is_container< DerivedCont, aterm >::value &&std::is_same_v< Cont< typename DerivedCont::value_type >, DerivedCont > &&is_convertible< Base, typename DerivedCont::value_type >::value > *=nullptr)
Definition aterm.h:409
Derived & reference_cast(Base &t, typename std::enable_if< is_convertible< Base, Derived >::value &&!std::is_base_of< Derived, Base >::value >::type *=nullptr)
A cast from one aterm based type to another, as a reference, allowing to assign to it.
Definition aterm.h:352
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:50
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:53
void mcrl2_unused(T &&...)
Function that can be used to silence unused parameter warnings.
Definition unused.h:20
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
void swap(atermpp::aterm &t1, atermpp::aterm &t2) noexcept
Swaps two term_applss.
Definition aterm.h:475
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:462
int main(int argc, char *argv[])
_aterm_appl_allocator< U > other
Definition aterm.h:136
Returns true iff first and second are value-equivalent.
Definition aterm_hash.h:125
Computes the hash of the given term.
Definition aterm_hash.h:101
Computes the hash of the given term.
Definition aterm_hash.h:85
Returns true iff the given term(s) or value are equivalent.
Definition aterm_hash.h:149
Computes the hash of the integral term arguments.
Definition aterm_hash.h:113
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:41
A typetrait that is std::true_type iff std::begin() and std::end() can be called on type T.
Definition type_traits.h:21
A typetrait that is std::true_type iff the given type has the iterator traits.
Definition type_traits.h:31
std::size_t operator()(const atermpp::aterm &t) const
Definition aterm.h:483
std::size_t operator()(const atermpp::aterm_core &t) const
Definition aterm_hash.h:63
std::size_t operator()(const atermpp::detail::reference_aterm< T > &t) const
std::size_t operator()(const mcrl2::utilities::tagged_pointer< T > &p) const