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

Wrong use of std::conditional_variable::wait() ? #850

Closed
z16166 opened this issue Jul 18, 2024 · 2 comments · Fixed by #851
Closed

Wrong use of std::conditional_variable::wait() ? #850

z16166 opened this issue Jul 18, 2024 · 2 comments · Fixed by #851

Comments

@z16166
Copy link
Contributor

z16166 commented Jul 18, 2024

may be wrong code:

                std::unique_lock<std::mutex> lock(start_mutex_);
                if (!server_started_)
                    cv_started_.wait(lock);

correct:

                std::unique_lock<std::mutex> lock(start_mutex_);
                while (!server_started_)
                    cv_started_.wait(lock);

or:

                std::unique_lock<std::mutex> lock(start_mutex_);
                cv_started_.wait(lock, [](){ return server_started_; });


@gittiver
Copy link
Member

Hi, could yo add it as pull request? Have to search the code for it.

@z16166
Copy link
Contributor Author

z16166 commented Jul 19, 2024

Hi, could yo add it as pull request? Have to search the code for it.

done.
#851

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 a pull request may close this issue.

2 participants