Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <memory> 7 : 8 : #include "DataStructures/DataBox/DataBox.hpp" 9 : #include "Parallel/NodeLock.hpp" 10 : 11 : namespace Parallel::Actions { 12 : /*! 13 : * \brief A local synchronous action that returns a pointer to the item 14 : * specified by the tag. 15 : * 16 : * The action uses `db::get_mutable_reference` to avoid DataBox locking 17 : * interference. However, this means that thread safety with respect to the 18 : * retrieved tag must be ensured by the user. 19 : */ 20 : template <typename Tag> 21 1 : struct GetItemFromDistributedOject { 22 0 : using return_type = typename Tag::type*; 23 : 24 : template <typename ParallelComponent, typename DbTagList> 25 0 : static return_type apply( 26 : db::DataBox<DbTagList>& box, 27 : const gsl::not_null<Parallel::NodeLock*> /*node_lock*/) { 28 : return std::addressof(db::get_mutable_reference<Tag>(make_not_null(&box))); 29 : } 30 : }; 31 : } // namespace Parallel::Actions