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

Case Study: C++ Thread-Safety Concurrency #4

Open
kassane opened this issue May 20, 2023 · 5 comments
Open

Case Study: C++ Thread-Safety Concurrency #4

kassane opened this issue May 20, 2023 · 5 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@kassane
Copy link
Owner

kassane commented May 20, 2023

Getting briefly talked about in the last PR.

The plan is to begin to investigate a case for implementing a solution for concurrency that is compatible with the API of the tb_client library.

Note: The latest commit, C++ version has been downgraded to 14. It is not necessary to have the latest version for a proposal.
However, nothing prohibits a better implementation!

#2 (comment)

I think C++ could follow the same strategy we have with Java/C# clients, exposing both async and blocking APIs.
An idiomatic C++ API could provide an async API by exposing a high-level callback/lambda, or even explore modern C++ async (is that a use case for promises?).

cc: @batiati @kprotty

Reference

@kassane kassane added enhancement New feature or request help wanted Extra attention is needed labels May 20, 2023
@kassane
Copy link
Owner Author

kassane commented May 23, 2023

Why std::async isn't async?

std::async returns a std::future object.

std::future::~future

these actions will not block for the shared state to become ready, except that it may block if all of the following are true: the shared state was created by a call to std::async, the shared state is not yet ready, and this was the last reference to the shared state.

Ref:

@kassane
Copy link
Owner Author

kassane commented May 24, 2023

Refactor: breaking API change for all clients

@zetanumbers
Copy link

Why std::async isn't async?

For async see this:
https://en.cppreference.com/w/cpp/language/coroutines

@kassane
Copy link
Owner Author

kassane commented May 27, 2023

@kassane
Copy link
Owner Author

kassane commented May 30, 2023

Initial in the last commit, the use of mutex lock_guard (RAII) was inserted to match the time in sending requests. (Sync)

As for the asynchronous method, it will need to be better evaluated to avoid possible cases of unnecessary complexity for a sample project.

Even based on my last asynchronous test (asio::coroutine [stackless]) demonstrated a high cost in memory allocations.
kprotty/zap#8

Another references:

@kassane kassane changed the title Case Study: C++ Thread-safe Concurrency Case Study: C++ Thread-Safety Concurrency Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants