ATLAS Offline Software
RCUUpdater.icc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration.
3  */
4 // $Id$
5 /**
6  * @file AthenaKernel/RCUUpdater.icc
7  * @author scott snyder <snyder@bnl.gov>
8  * @date Nov, 2017
9  * @brief Implementation of Updater for RCUSvc.
10  */
11 
12 
13 namespace Athena {
14 
15 
16 /**
17  * @brief Constructor.
18  * @param rcusvc RCU service instance.
19  * @param args Additional arguments to pass to the T constructor.
20  *
21  * Creates a new instance of T.
22  */
23 template <class T>
24 template <typename... Args>
25 RCUUpdater<T>::RCUUpdater (IRCUSvc& rcusvc, Args&&... args)
26  : m_obj (rcusvc, std::forward<Args>(args)...)
27 {
28 }
29 
30 
31 /**
32  * @brief Install a new object.
33  * @param p The new object to install.
34  * @param ctx Current execution context.
35  *
36  * The existing object should not be deleted until it can no longer
37  * be referenced by any thread.
38  */
39 template <class T>
40 inline
41 void RCUUpdater<T>::update (std::unique_ptr<T> p, const Context_t& ctx)
42 {
43  m_obj.updater(ctx).update (std::move (p));
44 }
45 
46 
47 /**
48  * @brief Return a reference to the current object.
49  */
50 template <class T>
51 inline
52 const T& RCUUpdater<T>::get() const
53 {
54  return *m_obj.reader();
55 }
56 
57 
58 /**
59  * @brief Mark that an event slot is not referencing this object.
60  */
61 template <class T>
62 inline
63 void RCUUpdater<T>::quiescent (const Context_t& ctx)
64 {
65  m_obj.quiescent (ctx);
66 }
67 
68 
69 /**
70  * @brief Queue an object for later deletion.
71  * @param p The object to delete.
72  *
73  * The object @c p will be queued for deletion once a grace period
74  * has passed for all slots. In contrast to using @c updater,
75  * this does not change the current object. It also does not mark
76  * the current slot as having completed the grace period (so this can
77  * be called by a thread running outside of a slot context).
78  */
79 template <class T>
80 inline
81 void RCUUpdater<T>::discard (std::unique_ptr<T> p)
82 {
83  m_obj.discard (std::move (p));
84 }
85 
86 
87 /**
88  * @brief Return the current event context.
89  */
90 template <class T>
91 inline
92 const typename RCUUpdater<T>::Context_t&
93 RCUUpdater<T>::defaultContext()
94 {
95  return Gaudi::Hive::currentContext();
96 }
97 
98 
99 } // namespace Athena