sp_counted_base_acc_ia64.hpp
Go to the documentation of this file.
1 #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_ACC_IA64_HPP_INCLUDED
2 #define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_ACC_IA64_HPP_INCLUDED
3 
4 //
5 // detail/sp_counted_base_acc_ia64.hpp - aC++ on HP-UX IA64
6 //
7 // Copyright 2007 Baruch Zilber
8 // Copyright 2007 Boris Gubenko
9 //
10 // Distributed under the Boost Software License, Version 1.0. (See
11 // accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
13 //
14 //
15 // Lock-free algorithm by Alexander Terekhov
16 //
17 
19 #include <machine/sys/inline.h>
20 
21 namespace boost
22 {
23 
24 namespace detail
25 {
26 
27 inline void atomic_increment( int * pw )
28 {
29  // ++*pw;
30 
31  _Asm_fetchadd(_FASZ_W, _SEM_REL, pw, +1, _LDHINT_NONE);
32 }
33 
34 inline int atomic_decrement( int * pw )
35 {
36  // return --*pw;
37 
38  int r = static_cast<int>(_Asm_fetchadd(_FASZ_W, _SEM_REL, pw, -1, _LDHINT_NONE));
39  if (1 == r)
40  {
41  _Asm_mf();
42  }
43 
44  return r - 1;
45 }
46 
47 inline int atomic_conditional_increment( int * pw )
48 {
49  // if( *pw != 0 ) ++*pw;
50  // return *pw;
51 
52  int v = *pw;
53 
54  for (;;)
55  {
56  if (0 == v)
57  {
58  return 0;
59  }
60 
61  _Asm_mov_to_ar(_AREG_CCV,
62  v,
63  (_UP_CALL_FENCE | _UP_SYS_FENCE | _DOWN_CALL_FENCE | _DOWN_SYS_FENCE));
64  int r = static_cast<int>(_Asm_cmpxchg(_SZ_W, _SEM_ACQ, pw, v + 1, _LDHINT_NONE));
65  if (r == v)
66  {
67  return r + 1;
68  }
69 
70  v = r;
71  }
72 }
73 
75 {
76 private:
77 
80 
81  int use_count_; // #shared
82  int weak_count_; // #weak + (#shared != 0)
83 
84 public:
85 
87  {
88  }
89 
90  virtual ~sp_counted_base() // nothrow
91  {
92  }
93 
94  // dispose() is called when use_count_ drops to zero, to release
95  // the resources managed by *this.
96 
97  virtual void dispose() = 0; // nothrow
98 
99  // destroy() is called when weak_count_ drops to zero.
100 
101  virtual void destroy() // nothrow
102  {
103  delete this;
104  }
105 
106  virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
107  virtual void * get_untyped_deleter() = 0;
108 
110  {
112  }
113 
114  bool add_ref_lock() // true on success
115  {
117  }
118 
119  void release() // nothrow
120  {
121  if( atomic_decrement( &use_count_ ) == 0 )
122  {
123  dispose();
124  weak_release();
125  }
126  }
127 
128  void weak_add_ref() // nothrow
129  {
131  }
132 
133  void weak_release() // nothrow
134  {
135  if( atomic_decrement( &weak_count_ ) == 0 )
136  {
137  destroy();
138  }
139  }
140 
141  long use_count() const // nothrow
142  {
143  return static_cast<int const volatile &>( use_count_ ); // TODO use ld.acq here
144  }
145 };
146 
147 } // namespace detail
148 
149 } // namespace boost
150 
151 #endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_ACC_IA64_HPP_INCLUDED
boost::detail::atomic_increment
void atomic_increment(int *pw)
Definition: sp_counted_base_acc_ia64.hpp:27
boost::detail::sp_counted_base::get_untyped_deleter
virtual void * get_untyped_deleter()=0
boost
BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.
boost::detail::sp_counted_base
Definition: sp_counted_base_acc_ia64.hpp:74
boost::detail::sp_counted_base::destroy
virtual void destroy()
Definition: sp_counted_base_acc_ia64.hpp:101
boost::detail::sp_counted_base::add_ref_copy
void add_ref_copy()
Definition: sp_counted_base_acc_ia64.hpp:109
sp_typeinfo.hpp
boost::detail::sp_counted_base::weak_release
void weak_release()
Definition: sp_counted_base_acc_ia64.hpp:133
boost::detail::sp_counted_base::add_ref_lock
bool add_ref_lock()
Definition: sp_counted_base_acc_ia64.hpp:114
boost::detail::sp_typeinfo
boost::core::typeinfo sp_typeinfo
Definition: sp_typeinfo.hpp:28
boost::detail::sp_counted_base::get_deleter
virtual void * get_deleter(sp_typeinfo const &ti)=0
boost::detail::sp_counted_base::use_count
long use_count() const
Definition: sp_counted_base_acc_ia64.hpp:141
boost::detail::sp_counted_base::dispose
virtual void dispose()=0
boost::detail::sp_counted_base::~sp_counted_base
virtual ~sp_counted_base()
Definition: sp_counted_base_acc_ia64.hpp:90
boost::detail::sp_counted_base::operator=
sp_counted_base & operator=(sp_counted_base const &)
boost::detail::atomic_conditional_increment
int atomic_conditional_increment(int *pw)
Definition: sp_counted_base_acc_ia64.hpp:47
boost::detail::sp_counted_base::sp_counted_base
sp_counted_base()
Definition: sp_counted_base_acc_ia64.hpp:86
boost::detail::sp_counted_base::release
void release()
Definition: sp_counted_base_acc_ia64.hpp:119
boost::detail::atomic_decrement
int atomic_decrement(int *pw)
Definition: sp_counted_base_acc_ia64.hpp:34
boost::detail::sp_counted_base::use_count_
int use_count_
Definition: sp_counted_base_acc_ia64.hpp:81
boost::detail::sp_counted_base::weak_count_
int weak_count_
Definition: sp_counted_base_acc_ia64.hpp:82
boost::detail::sp_counted_base::weak_add_ref
void weak_add_ref()
Definition: sp_counted_base_acc_ia64.hpp:128


sick_visionary_ros
Author(s): SICK AG TechSupport 3D Snapshot
autogenerated on Thu Feb 8 2024 03:48:40