Line data Source code
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_DETAIL_GLOBAL_ATERM_POOL_H_ 11 : #define MCRL2_ATERMPP_DETAIL_GLOBAL_ATERM_POOL_H_ 12 : 13 : #include "mcrl2/atermpp/detail/aterm_pool.h" 14 : #include "mcrl2/atermpp/detail/thread_aterm_pool.h" 15 : 16 : namespace atermpp 17 : { 18 : namespace detail 19 : { 20 : 21 : /// \brief Storage for a global term pool that is not initialized. 22 : extern typename std::aligned_storage<sizeof(aterm_pool), alignof(aterm_pool)>::type g_aterm_pool_storage; 23 : 24 : /// \brief A reference to the global term pool storage 25 : static aterm_pool& g_aterm_pool_instance = *static_cast<aterm_pool*>(static_cast<void*>(&g_aterm_pool_storage)); 26 : 27 : /// \brief obtain a reference to the global aterm pool. 28 : /// \details provides lazy initialization which should be used when instantiating 29 : /// global terms and function symbols. 30 : template<bool lazy = false> 31 11689825927 : inline aterm_pool& g_term_pool() 32 : { 33 : if (lazy) 34 : { 35 : static bool initialized = false; 36 20647 : if (!initialized) 37 : { 38 143 : new (&g_aterm_pool_instance) aterm_pool(); 39 143 : initialized = true; 40 : } 41 : } 42 : 43 11689825927 : return g_aterm_pool_instance; 44 : } 45 : 46 : // Implemented in a .cpp file. 47 : //thread_aterm_pool& g_thread_term_pool(); 48 : 49 : } // namespace detail 50 : } // namespace atermpp 51 : 52 : #include "mcrl2/atermpp/detail/aterm_implementation.h" 53 : 54 : #endif // MCRL2_ATERMPP_DETAIL_GLOBAL_ATERM_POOL_H_