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

Name change request #5

Closed
windelbouwman opened this issue Mar 18, 2021 · 1 comment
Closed

Name change request #5

windelbouwman opened this issue Mar 18, 2021 · 1 comment

Comments

@windelbouwman
Copy link

Currently, the way to start a new fiber, is by using the keyword async. This might be somewhat confusing for people coming from C# or Python (like me).

I'd like to suggest renaming async to spawn, so that it is clear a fiber is spawned at that point in the code.

Another thing which is available in python and C# is the await keyword, this could be useful to await the returned futures. Maybe a macro for this would be a nice syntactic sugar.

@jhrutgers
Copy link
Owner

async matches the behavior of std::async, so the term seems to make sense. However, being a macro may lead to issues when including other headers, such as <future> (although that specific header would not be needed when using Zth). Using such kind of macros with commonly used names may not be feasible in the long run anyway. So, I made the following changes for version 1.1.0:

  • zth_async is defined as the original behavior of async. To prevent defining async, make sure to define ZTH_NO_ASYNC_KEYWORD before including <zth>. Then, you are free to define your own spawn to zth_async.
  • zth::fiber() is added to create a fiber. It can be used instead of async. See the 7_no_async example.

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

2 participants