-
Notifications
You must be signed in to change notification settings - Fork 248
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
SpinLock.POC #99
SpinLock.POC #99
Conversation
chenbo seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
you'd better add a new example for testing spinlock, don't modify the current case. |
... It's not a contribution. It's a demo to show the bug. |
Ok, we will try to test it, and can you supply the backtrace of segment fault? |
This might be a mis-use. We need to pass an executor in the start point of the async chain. But the diagnostic message from the library side is not friendly indeed. We would try to enhance it. Thanks for reporting. |
char write_buf[max_length] = {"hello async_simple"}; | ||
char read_buf[max_length]; | ||
auto send = [&]() -> async_simple::coro::Lazy<> { | ||
auto scopeLock = co_await g_wlock.coScopedLock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coScopedLock need a executor to reschedule current coroutine to avoid the others be blocked, but this demo code use syncAwait to start a lazy task (without executor), so segment fault occurred
you can use ScopedSpinLock to avoid the coroutine yield or pass a executor to syncAwait
eg:
async_simple::coro::syncAwait(start(io_context, "127.0.0.1", "9980").via(executor));
I think what I need is a mutex(based on coroutine). I didn’t find it in the code. |
And what kind of executor should I use there? |
ok, mutex is working on |
just use async_simple::executors::SimpleExecutor for test |
Is coScopedLock + executor sufficient to run my test? Because you said mutex is still under development … I’m a little confused |
yes |
I have updated the code and added the Executor, now this test case is able to run. But as long as I increase the
|
Looks like the coScopedLock + executor is not working as expected as a mutex does. Something is blocked. |
} | ||
input.push_back(show_qps()); | ||
co_await async_simple::coro::collectAll(std::move(input)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collectAll run multi coroutines in same thread asynchronously, looks like you want all coroutines parallel on all thread, try to use collectAllPara
?
Thanks for reporting. I've got a similar results. And my conclusions are:
A condition variable here might be better. |
@beef9999 Given there is no other comment. I am going close this one. Thanks for contributing. |
No description provided.