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 cco macro, block style coroutine definition #57

Merged
merged 1 commit into from May 24, 2023
Merged

Conversation

liigo
Copy link
Contributor

@liigo liigo commented May 18, 2023

to replace cco_begin(co) && cco_end().

int task1(struct context_t *ctx) {
    cco(ctx) {
        puts("1");
        cco_yield(1);
        puts("2");
        cco_yield(2);
        puts("3");
        cco_yield(3);
    }
    puts("ending");
    return -99;
}

@tylov
Copy link
Collaborator

tylov commented May 24, 2023

@liigo, this is just brilliant! Thank you! There are only a few things to fix:

  1. I think the name cco() is very short for a public library macro, and not very descriptive. Maybe cco_routine() would be clearer for readers who are not closely familiar with STC (yet :). Or do you have a better suggestion?
  2. Both cco_begin() and cco_end() macros should be removed.
  3. That means replace cco_begin(x); ... cco_end() with cco_routine(x) { ... } in all examples so they compile. (examples will be reorganised/filtered at some point).
  4. In cco_await_2, replace return ret; with {return ret; goto _begin;} to avoid unused label warning (as you did in cco_yield).
  5. I can update the documentation later.

@tylov tylov merged commit 8a19b4d into stclib:dev43 May 24, 2023
1 check passed
@tylov
Copy link
Collaborator

tylov commented May 24, 2023

I decided to accept your PR as it is, and I will do some cleanup myself later, i.e. rename cco() to cco_routine().
Thank you again.

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.

None yet

2 participants