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

feat: coroutines "beta test" #763

Merged
merged 9 commits into from
Aug 21, 2023
Merged

Conversation

Mishura4
Copy link
Member

@Mishura4 Mishura4 commented Aug 8, 2023

dpp::task - coroutine object

Hot start (starts on constructor), executes in parallel
Can be cancelled which will throw dpp::task_cancelled_exception after the next co_await
Cannot detach, task will cancel itself when destroyed
Can be co-awaited later to retrieve return value
Requires synchronization at the point of co_await and destruction (lock-free)

dpp::coroutine - coroutine object

Lazy start (starts on co_await)
Has a return value, retrieved on co_await
Cannot detach or run in parallel by design of lazy start
No synchronization, light object

dpp::job - coroutine object

Hot start, runs in parallel and detached always, destroys itself when done
Cannot be co_awaited
No synchronization, no return value, very light object

dpp::async - awaitable API request (previously dpp::awaitable)

Can be constructed from a function
e.g:

  • returned by co_*: dpp:async request = cluster->co_message_create(dpp::message{"foobar"});
  • from arbitrary function: dpp::async request{cluster, &dpp::cluster::message_create, dpp::message{"foobar"}};

Hot start (starts on constructor), executes in parallel
Lock-free synchronization on co_await

@netlify
Copy link

netlify bot commented Aug 8, 2023

Deploy Preview for dpp-dev ready!

Name Link
🔨 Latest commit 2cbc430
🔍 Latest deploy log https://app.netlify.com/sites/dpp-dev/deploys/64e3b96fc5333500073fcc83
😎 Deploy Preview https://deploy-preview-763--dpp-dev.netlify.app/coroutines
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Mishura4 Mishura4 added enhancement New feature or request project labels Aug 8, 2023
@Mishura4 Mishura4 self-assigned this Aug 8, 2023
@Mishura4 Mishura4 force-pushed the coroutine branch 8 times, most recently from 9dc4d8c to b13caae Compare August 15, 2023 19:39
@Mishura4 Mishura4 force-pushed the coroutine branch 4 times, most recently from 40877c0 to 921e040 Compare August 15, 2023 22:14
@Mishura4 Mishura4 changed the title [work-in-progress] feat: more coroutine goodies feat: coroutines "beta test" Aug 15, 2023
@Mishura4
Copy link
Member Author

Mishura4 commented Aug 16, 2023

Depends on #775 as one of the examples in the docs gets a SIGSEGV from the destructor of a copied dpp::emoji
✅ Merged

@Mishura4 Mishura4 force-pushed the coroutine branch 4 times, most recently from 6e6ba3b to 49b2cb5 Compare August 21, 2023 14:13
@CLAassistant
Copy link

CLAassistant commented Aug 21, 2023

CLA assistant check
All committers have signed the CLA.

@wizard7377
Copy link
Contributor

Please wrap all C++20 specific features in a #if __cplusplus != 201703L and #endif

@Mishura4
Copy link
Member Author

DPP_CORO covers that.

Mishura4 added a commit to Mishura4/DPP-PRs that referenced this pull request Aug 21, 2023
Mishura4 added a commit to Mishura4/DPP-PRs that referenced this pull request Aug 21, 2023
@Mishura4 Mishura4 marked this pull request as ready for review August 21, 2023 19:06
@Mishura4
Copy link
Member Author

This is finally ready for review. 👍

Mishura4 added a commit to Mishura4/DPP-PRs that referenced this pull request Aug 21, 2023
@Mishura4
Copy link
Member Author

Btw I suggest merging this PR normally, without squash, so each changes gets listed in the changelog one by one

@braindigitalis braindigitalis merged commit 6c344a1 into brainboxdotcc:dev Aug 21, 2023
28 checks passed
@Mishura4 Mishura4 deleted the coroutine branch August 22, 2023 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants