libs/capy/include/boost/capy/ex/frame_allocator.hpp
100.0% Lines (2/2)
100.0% Functions (1/1)
-% Branches (0/0)
libs/capy/include/boost/capy/ex/frame_allocator.hpp
| Line | Hits | Source Code |
|---|---|---|
| 1 | // | |
| 2 | // Copyright (c) 2025 Vinnie Falco (vinnie dot falco at gmail dot com) | |
| 3 | // | |
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |
| 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
| 6 | // | |
| 7 | // Official repository: https://github.com/cppalliance/capy | |
| 8 | // | |
| 9 | ||
| 10 | #ifndef BOOST_CAPY_FRAME_ALLOCATOR_HPP | |
| 11 | #define BOOST_CAPY_FRAME_ALLOCATOR_HPP | |
| 12 | ||
| 13 | #include <boost/capy/detail/config.hpp> | |
| 14 | #include <boost/capy/detail/frame_memory_resource.hpp> | |
| 15 | ||
| 16 | #include <memory_resource> | |
| 17 | ||
| 18 | namespace boost { | |
| 19 | namespace capy { | |
| 20 | ||
| 21 | /** Thread-local storage for the current frame allocator. | |
| 22 | ||
| 23 | This function returns a reference to the thread-local pointer | |
| 24 | that holds the current memory_resource for frame allocation. | |
| 25 | The pointer is set by run_async before creating any tasks. | |
| 26 | ||
| 27 | @return Reference to the thread-local memory_resource pointer. | |
| 28 | */ | |
| 29 | inline std::pmr::memory_resource*& | |
| 30 | 16690 | current_frame_allocator() noexcept |
| 31 | { | |
| 32 | static thread_local std::pmr::memory_resource* mr = nullptr; | |
| 33 | 16690 | return mr; |
| 34 | } | |
| 35 | ||
| 36 | // For backward compatibility | |
| 37 | using detail::frame_memory_resource; | |
| 38 | ||
| 39 | } // namespace capy | |
| 40 | } // namespace boost | |
| 41 | ||
| 42 | #endif | |
| 43 |