File indexing completed on 2025-01-31 09:37:22
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_FIBERS_DETAIL_SHARED_STATE_OBJECT_H
0008 #define BOOST_FIBERS_DETAIL_SHARED_STATE_OBJECT_H
0009
0010 #include <memory>
0011
0012 #include <boost/config.hpp>
0013
0014 #include <boost/fiber/detail/config.hpp>
0015 #include <boost/fiber/future/detail/shared_state.hpp>
0016
0017 #ifdef BOOST_HAS_ABI_HEADERS
0018 # include BOOST_ABI_PREFIX
0019 #endif
0020
0021 namespace boost {
0022 namespace fibers {
0023 namespace detail {
0024
0025 template< typename R, typename Allocator >
0026 class shared_state_object : public shared_state< R > {
0027 public:
0028 typedef typename std::allocator_traits< Allocator >::template rebind_alloc<
0029 shared_state_object
0030 > allocator_type;
0031
0032 shared_state_object( allocator_type const& alloc) :
0033 shared_state< R >{},
0034 alloc_{ alloc } {
0035 }
0036
0037 protected:
0038 void deallocate_future() noexcept override final {
0039 destroy_( alloc_, this);
0040 }
0041
0042 private:
0043 allocator_type alloc_;
0044
0045 static void destroy_( allocator_type const& alloc, shared_state_object * p) noexcept {
0046 allocator_type a{ alloc };
0047 typedef std::allocator_traits< allocator_type > traity_type;
0048 traity_type::destroy( a, p);
0049 traity_type::deallocate( a, p, 1);
0050 }
0051 };
0052
0053 }}}
0054
0055 #ifdef BOOST_HAS_ABI_HEADERS
0056 # include BOOST_ABI_SUFFIX
0057 #endif
0058
0059 #endif