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

simple usage of transform & sync_wait with compile error #368

Closed
zeyangl opened this issue Nov 2, 2021 · 4 comments
Closed

simple usage of transform & sync_wait with compile error #368

zeyangl opened this issue Nov 2, 2021 · 4 comments

Comments

@zeyangl
Copy link

zeyangl commented Nov 2, 2021

I tried writing a shortest unifex example possible and came up with this

image

I'm curious as why sync_wait is not compiling. The error is a bit too obfiscated for someone not very familiar with unifex yet. If I return void from the second function it works fine. After inspecting transform's definition it seems to allow returning custom values.

I'm using vcpkg's version of unifex(when "then" is still "transform"), and in visual studio 2019.

Thanks.

@RishabhRD
Copy link
Contributor

RishabhRD commented Nov 2, 2021

I am not an expert but, I don't know if [](){} is even a sender. You can try:

  auto cc = then(just(), [] { return 0; });
  auto x = sync_wait(cc);
  EXPECT_EQ(x.value(), 0);

You can use transform if you are using that version. As of my limited knowledge, just() is a sender that just completes by calling set_value() with no arguments (If just is called with arguments it would call set_value with those arguments). So, it should serve your purpose.

@zeyangl
Copy link
Author

zeyangl commented Nov 2, 2021

Thanks. I thought the lambda could be implicitly packaged as a sender. I went through the unit tests and found them to be very helpful learning the patterns.

@kirkshoop
Copy link
Contributor

@RishabhRD is correct.
Thanks for the question and the answer!

@zeyangl
Copy link
Author

zeyangl commented Nov 2, 2021

It might be helpful to point readers to the unit tests from the docs, better than examples for initial learning. It's been 2 days and I just realized that's where I should look first.

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

No branches or pull requests

3 participants