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

Async ref #81

Merged
merged 2 commits into from
Aug 18, 2017
Merged

Async ref #81

merged 2 commits into from
Aug 18, 2017

Conversation

sean-parent
Copy link
Member

@FelixPetriconi - can you take a look at this? Added support for std::ref per issue #80. Required quite a bit of meta- scaffolding.

@codecov
Copy link

codecov bot commented Aug 18, 2017

Codecov Report

Merging #81 into develop will increase coverage by 0.09%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #81      +/-   ##
===========================================
+ Coverage    94.74%   94.83%   +0.09%     
===========================================
  Files           33       34       +1     
  Lines         4206     4280      +74     
  Branches       214      214              
===========================================
+ Hits          3985     4059      +74     
  Misses          85       85              
  Partials       136      136
Impacted Files Coverage Δ
stlab/concurrency/future.hpp 87.98% <100%> (-0.03%) ⬇️
test/future_tests.cpp 97.97% <100%> (+3.69%) ⬆️
stlab/test/model.hpp 94.11% <100%> (+6.61%) ⬆️
stlab/utility.hpp 100% <100%> (ø)
test/channel_test_helper.hpp 92.5% <0%> (-1.25%) ⬇️
test/future_then_tests.cpp 99.51% <0%> (+0.24%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 255379c...50e5795. Read the comment docs.

auto p = package<result_type()>(
executor, std::bind<result_type>(
[_f = std::forward<F>(f)](unwrap_reference_t<std::decay_t<Args>> &
... args) mutable->result_type {
Copy link
Member

Choose a reason for hiding this comment

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

The line wrapping here is strange. Probably a result of clangformat?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, clang-format is getting lost on that line.

Copy link
Member

@FelixPetriconi FelixPetriconi left a comment

Choose a reason for hiding this comment

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

The changes are fine for me. But I think we should add a test for this as well so that we will have this as regression as well.

@ahcox
Copy link

ahcox commented Aug 18, 2017

You guys are efficient! Note I think this also addresses std::cref().
(An object passed to std::async() by const reference is copied unless std::cref() is used to wrap it)
I updated my repro to have a std::cref() example (https://gist.github.com/ahcox/0e76d32a0a87ac24160bf50298052a1d). This all compiles fine now using the async-ref branch.

@sean-parent
Copy link
Member Author

I will add some test cases.
@ahcox, this also handles the cref() case correctly without copies. Simple test:

#include <stlab/concurrency/future.hpp>
#include <stlab/concurrency/immediate_executor.hpp>
#include <stlab/test/model.hpp>

int main() {
    stlab::annotate a;
    stlab::async(stlab::immediate_executor, [](const auto& x) -> const auto& { return x; },
                 std::cref(a));
}

@sean-parent
Copy link
Member Author

I added test cases and reworked annotate to make it more useful for generating tests. See the new future tests for async to see how to use it.

@sean-parent sean-parent merged commit 0ff6e29 into develop Aug 18, 2017
@sean-parent sean-parent deleted the async-ref branch August 18, 2017 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants