Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify that capture by ref host_task requires caution #515

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions adoc/chapters/acknowledgements.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* Verena Beckham, Codeplay
* Aidan Belton, Codeplay
* Gordon Brown, Codeplay
* Hugh Delaney, Codeplay
* Morris Hafner, Codeplay
* Alexander Johnston, Codeplay
* Marios Katsigiannis, Codeplay
Expand Down
9 changes: 9 additions & 0 deletions adoc/chapters/programming_interface.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14622,6 +14622,15 @@ interoperability member functions provided by the [code]#interop_handle# class.

Local <<accessor,accessors>> cannot be used within a <<host-task>>.

[NOTE]
====
If a C++ lambda is passed to a <<host-task>>, the lambda may capture by
reference or by value.
Since the <<host-task>> callable executes asynchronously, care must be taken to
ensure that lifetimes of objects captured by reference by a <<host-task>> lambda
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even for objects captured by copy you still need to unsure that it works under the hood with the program logic.
The trivial example is a std::ref or a pointer captured by copy. ;-)

last at least until the <<host-task>> completes.
====

// TODO: access mode/target resolution rules

[source,,linenums]
Expand Down