Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7431015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:13:49+00:00 2026-05-29T09:13:49+00:00

Situation I’ve got a worker thread that’s being triggered by a condition_variable to do

  • 0

Situation

I’ve got a worker thread that’s being triggered by a condition_variable to do some work. Basically it is working very good and as supposed.

Problem

However there’s one problem: The thread launching the worker thread may get a long enough time slice to feed the data queue and notify the condition_variable when the worker thread is not ready yet, i.e. when it didn’t reach the condition_variable.wait() line yet.

Is there any way I can wait for a worker thread until the first call to wait() is made so it’s guaranteed that work will be processed when I notify the worker?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:13:50+00:00Added an answer on May 29, 2026 at 9:13 am

    There’s no reason to do that. When the worker thread is ready, it will do the work. It won’t need to be triggered by a condition variable because it won’t ever wait.

    Waiting for something that has already happened is a coding error. If you might ever even think of doing that, you fundamentally don’t understand condition variables.

    Before a thread waits on a condition variable, it must make sure that there is something it needs to wait for. That thing must be protected by the mutex associated with the condition variable. And when the thread returns from the condition variable wait, it usually must re-test to see if it needs to wait again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Situation: We've got this DIV with thumbnails who need their src being changed on
Situation is that level of log4net is configured as 'Error' but there is some
Situation in short. For some reason reverse() method does not work. in PROJECT urls.py
Situation: I've got a SVN repository with lets say 100 revisions, rev. 100 being
Situation: I have a simple XML document that contains image information. I need to
Situation: text: a string R: a regex that matches part of the string. This
Situation: you've got a .swf embedded in an html page, and when you click
Situation: I have some persons with certain skills and they can/might belong to more
Situation: I want to provide a website service where users can enter some data
Situation: I am working to populate text entry boxes in a webpage with data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.