ATLAS Offline Software
Loading...
Searching...
No Matches
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
13namespace 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 */
23template <class T>
24template <typename... Args>
25RCUUpdater<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 */
39template <class T>
40inline
41void 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 */
50template <class T>
51inline
52const 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 */
61template <class T>
62inline
63void 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 */
79template <class T>
80inline
81void 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 */
90template <class T>
91inline
92const typename RCUUpdater<T>::Context_t&
93RCUUpdater<T>::defaultContext()
94{
95 return Gaudi::Hive::currentContext();
96}
97
98
99} // namespace Athena