Skip to content

Commit

Permalink
#1983: vrt_coll: do not capture on collection contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander authored and cz4rs committed Mar 30, 2023
1 parent c59b95c commit 38833d9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/vt/context/runnable_context/collection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
namespace vt { namespace ctx {

void Collection::start() {
set_();
set_(elm_);
}

void Collection::finish() {
Expand Down
5 changes: 3 additions & 2 deletions src/vt/context/runnable_context/collection.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ struct Collection {
void resume();

private:
std::function<void()> set_; /**< Set context function */
std::function<void()> clear_; /**< Clear context function */
std::function<void(void* in_elm)> set_; /**< Set context function */
std::function<void()> clear_; /**< Clear context function */
void* elm_ = nullptr; /**< The element (untyped) */
};

}} /* end namespace vt::ctx */
Expand Down
8 changes: 5 additions & 3 deletions src/vt/context/runnable_context/collection.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ template <typename IndexT>
/*explicit*/ Collection::Collection(
vrt::collection::Indexable<IndexT>* elm
) {
auto idx_ = elm->getIndex();
auto proxy_ = elm->getProxy();
set_ = [=]{
elm_ = elm;
set_ = [](void* in_elm){
auto e = static_cast<vrt::collection::Indexable<IndexT>*>(in_elm);
auto& idx_ = e->getIndex();
auto proxy_ = e->getProxy();
vrt::collection::CollectionContextHolder<IndexT>::set(&idx_, proxy_);
};
clear_ = []{
Expand Down

0 comments on commit 38833d9

Please sign in to comment.