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

Add the async_run macro #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aedrax
Copy link

@aedrax aedrax commented Jan 9, 2022

I like how you have the await macro built, but it wasn't usable from a synchronous function like main, so I made this alternative. I know it isn't super necessary, but I really like the way it pulls together with the rest of the async.h project

@naasking
Copy link
Owner

Sorry for the lateness here, I only just recently had enough time to start getting back into this stuff. My only concern with this macro is that it blocks due to the hidden loop, so someone could inadvertently call it from inside an async function thinking it will implicitly yield. That's why all current async_* macros have no blocking semantics. Minor nitpick maybe, but the while loop doesn't add much code anyway so I'm not totally convinced it's needed.

A name that makes this very clear might be acceptable:

#define block_until(cond) while (!(cond))

Then it's maybe a little clearer what's going on:

block_until( driver_thread(&driver_pt) == ASYNC_DONE );

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.

2 participants