Skip to content

Commit

Permalink
#1554: DR: return a shared_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Oct 4, 2021
1 parent eab57e9 commit 666fec9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/hello_world/hello_world.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static void hello_world(HelloMsg* msg) {
my_reader.fetch(0);
vt::theSched()->runSchedulerWhile([&]{ return not my_reader.isReady(); });
auto const& vec = my_reader.get(0);
for (auto&& elm : vec) {
for (auto&& elm : *vec) {
vt_print(gen, "elm={}\n", elm);
}
fmt::print("{}: Hello from node {}\n", this_node, msg->from);
Expand Down
2 changes: 1 addition & 1 deletion src/vt/datarep/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct Reader : ReaderBase {

void fetch(DataVersionType version);

T const& get(DataVersionType version) const;
std::shared_ptr<T const> get(DataVersionType version) const;

private:
friend struct DataReplicator;
Expand Down
4 changes: 2 additions & 2 deletions src/vt/datarep/reader.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ void Reader<T>::fetch(DataVersionType version) {
}

template <typename T>
T const& Reader<T>::get(DataVersionType version) const {
std::shared_ptr<T const> Reader<T>::get(DataVersionType version) const {
vtAssert(ready_, "Data must be ready to get it");
vtAssert(data_ != nullptr, "Must have data");
return *data_;
return data_;
}

}} /* end namespace vt::datarep */
Expand Down

0 comments on commit 666fec9

Please sign in to comment.