]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/fiber/detail/fss.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / fiber / detail / fss.hpp
CommitLineData
7c673cae
FG
1
2// Copyright Oliver Kowalke 2013.
3// Distributed under the Boost Software License, Version 1.0.
4// (See accompanying file LICENSE_1_0.txt or copy at
5// http://www.boost.org/LICENSE_1_0.txt)
6//
7// based on tss.hpp from boost.thread
8
9#ifndef BOOST_FIBERS_DETAIL_FSS_H
10#define BOOST_FIBERS_DETAIL_FSS_H
11
12#include <atomic>
13#include <cstddef>
14
15#include <boost/config.hpp>
16#include <boost/intrusive_ptr.hpp>
17
18#ifdef BOOST_HAS_ABI_HEADERS
19# include BOOST_ABI_PREFIX
20#endif
21
22namespace boost {
23namespace fibers {
24namespace detail {
25
26class fss_cleanup_function {
27private:
28 std::atomic< std::size_t > use_count_{ 0 };
29
30public:
31 typedef intrusive_ptr< fss_cleanup_function > ptr_t;
32
1e59de90 33 fss_cleanup_function() = default;
7c673cae
FG
34
35 virtual ~fss_cleanup_function() = default;
36
37 virtual void operator()( void * data) = 0;
38
39 friend inline
40 void intrusive_ptr_add_ref( fss_cleanup_function * p) noexcept {
b32b8144 41 p->use_count_.fetch_add( 1, std::memory_order_relaxed);
7c673cae
FG
42 }
43
44 friend inline
45 void intrusive_ptr_release( fss_cleanup_function * p) noexcept {
b32b8144
FG
46 if ( 1 == p->use_count_.fetch_sub( 1, std::memory_order_release) ) {
47 std::atomic_thread_fence( std::memory_order_acquire);
7c673cae
FG
48 delete p;
49 }
50 }
51};
52
53}}}
54
55#ifdef BOOST_HAS_ABI_HEADERS
56# include BOOST_ABI_SUFFIX
57#endif
58
59#endif // BOOST_FIBERS_DETAIL_FSS_H