mCRL2
Loading...
Searching...
No Matches
aterm_implementation.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 MCRL2_ATERMPP_ATERM_IMPLEMENTATION_H
11#define MCRL2_ATERMPP_ATERM_IMPLEMENTATION_H
12#pragma once
13
16
17namespace atermpp
18{
19
20namespace detail
21{
22 template<typename T>
23 const reference_aterm<T, typename std::enable_if_t<std::is_base_of<aterm_core, T>::value>>&
24 reference_aterm<T, typename std::enable_if_t<std::is_base_of<aterm_core, T>::value>>::operator=(const unprotected_aterm_core& other) noexcept
25 {
27 m_term = address(other);
28 return *this;
29 }
30
31 template<typename T>
32 const reference_aterm<T, typename std::enable_if_t<std::is_base_of<aterm_core, T>::value>>&
33 reference_aterm<T, typename std::enable_if_t<std::is_base_of<aterm_core, T>::value>>::operator=(unprotected_aterm_core&& other) noexcept
34 {
36 m_term = address(other);
37 return *this;
38 }
39
40 template<typename T, typename Allocator>
42 {
44 m_allocator.deallocate(p, n);
45 }
46
47 inline
48 aterm_container::aterm_container(std::function<void(term_mark_stack&)> mark_func, std::function<std::size_t()> size_func)
49 : mark_func(mark_func),
50 size_func(size_func)
51 {
53 }
54
55 inline
57 {
59 }
60}
61
62inline aterm_core::aterm_core() noexcept
63{
65}
66
67inline aterm_core::~aterm_core() noexcept
68{
70}
71
72inline aterm_core::aterm_core(const detail::_aterm *t) noexcept
73{
75 m_term = t;
76}
77
78inline aterm_core::aterm_core(const aterm_core& other) noexcept
79 : unprotected_aterm_core(other.m_term)
80{
82}
83
84inline aterm_core::aterm_core(aterm_core&& other) noexcept
85 : unprotected_aterm_core(other.m_term)
86{
88}
89
90inline aterm_core& aterm_core::operator=(const aterm_core& other) noexcept
91{
93 m_term = other.m_term;
94 return *this;
95}
96
99{
100 mcrl2::utilities::shared_guard guard = pool.lock_shared();
101 m_term = other.m_term;
102 return *this;
103}
104
105
106template <bool CHECK_BUSY_FLAG /* =true*/>
108{
110 m_term = other.m_term;
111 return *this;
112}
113
114
116{
118 // Using hash set protection it is cheaper just to move the value to the new term.
119 m_term = other.m_term;
120 return *this;
121}
122
123
124} // namespace atermpp
125
126#endif // MCRL2_ATERMPP_TERM_IMPLEMENTATION_H
The aterm_core base class that provides protection of the underlying shared terms.
Definition aterm_core.h:182
~aterm_core() noexcept
Standard destructor.
aterm_core & operator=(const aterm_core &other) noexcept
Assignment operator.
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.
This is the class to which an aterm points.
Definition aterm_core.h:48
aterm_container(std::function< void(term_mark_stack &)> mark_func, std::function< std::size_t()> size_func)
This is a thread's specific access to the global aterm pool which ensures that garbage collection and...
void deregister_container(aterm_container *variable)
Removes the given container from the active variables.
void register_container(aterm_container *variable)
Consider the given container when marking underlying terms.
void deregister_variable(aterm_core *variable)
Removes the given variable from the active variables.
bool is_shared_locked()
Returns true iff we are in a shared section.
void register_variable(aterm_core *variable)
Consider the given variable when marking underlying terms.
mcrl2::utilities::shared_guard lock_shared()
Acquire a shared lock on this thread aterm pool.
An unprotected term does not change the reference count of the shared term when it is copied or moved...
Definition aterm_core.h:32
const detail::_aterm * m_term
Definition aterm_core.h:36
A shared lock guard for the shared_mutex.
a pool allocator class
_aterm * address(const unprotected_aterm_core &t)
Definition aterm_core.h:239
thread_aterm_pool & g_thread_term_pool()
A reference to the thread local term pool storage.
The main namespace for the aterm++ library.
Definition algorithm.h:21
std::stack< std::reference_wrapper< detail::_aterm > > term_mark_stack
static constexpr bool GlobalThreadSafe
Enables thread safety for the whole toolset.