5 * Use, modification and distribution are subject to the
6 * Boost Software License, Version 1.0. (See accompanying file
7 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
12 * LOCATION: see http://www.boost.org for most recent version.
13 * FILE mem_block_cache.hpp
14 * VERSION see <boost/version.hpp>
15 * DESCRIPTION: memory block cache used by the non-recursive matcher.
18 #ifndef BOOST_REGEX_V4_MEM_BLOCK_CACHE_HPP
19 #define BOOST_REGEX_V4_MEM_BLOCK_CACHE_HPP
22 #ifdef BOOST_HAS_THREADS
23 #include <boost/regex/pending/static_mutex.hpp>
26 #ifdef BOOST_HAS_ABI_HEADERS
27 # include BOOST_ABI_PREFIX
38 struct mem_block_cache
40 // this member has to be statically initialsed:
42 unsigned cached_blocks;
43 #ifdef BOOST_HAS_THREADS
44 boost::static_mutex mut;
51 mem_block_node* old = next;
53 ::operator delete(old);
58 #ifdef BOOST_HAS_THREADS
59 boost::static_mutex::scoped_lock g(mut);
63 mem_block_node* result = next;
68 return ::operator new(BOOST_REGEX_BLOCKSIZE);
72 #ifdef BOOST_HAS_THREADS
73 boost::static_mutex::scoped_lock g(mut);
75 if(cached_blocks >= BOOST_REGEX_MAX_CACHE_BLOCKS)
81 mem_block_node* old = static_cast<mem_block_node*>(p);
89 extern mem_block_cache block_cache;
94 #ifdef BOOST_HAS_ABI_HEADERS
95 # include BOOST_ABI_SUFFIX