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 8376599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:28:02+00:00 2026-06-09T15:28:02+00:00

I have written a program using Boost threads. I have allocated two buffers (one

  • 0

I have written a program using Boost threads. I have allocated two buffers (one for each of the worker threads) to store some info they are to process. They sit and wait for something to appear on the buffer, then they process it and place the results onto a different buffer. My buffer implementations are thread-safe. At present, I have the main thread busy-wait until the buffer size is zero, however this is really inefficient as it has to keep requesting control of the buffer and then checking the size. I’d like a way to sleep the main thread until BOTH worker threads signal that they are finished. I am fairly sure this can be achieved using boost::condition_variable but I am unsure how I would do this with two worker threads.

Help greatly appreciated.

EDIT – Also, would boost::barrier be suitable also?

  • 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-06-09T15:28:04+00:00Added an answer on June 9, 2026 at 3:28 pm

    You may also use thread::join method. This method will wait that the thread finish (the thread function return).

    For more info about join.

    I don’t think that barrier can help you. Barrier allow to stop the thread processing until all the threads mets the barrier. When all the threads had called barrier::wait, then all the thread stop waiting.

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

Sidebar

Related Questions

I have written this program, which sorts some ints using a functor: #include<iostream> #include<list>
I have a really short program written in boost::xpressive #include <iostream> #include <boost/xpressive/xpressive.hpp> using
I have written a small example C++ program, using boost::thread. Since it's 215 lines,
I have a program written in C using ncurses. It let user input and
I have written my own hadoop program and I can run using pseudo distribute
I have a membership program written with PHP and using mysql where users input
I've written a program in C++. It's just using the console to have it
I have written a small program using Borland's C++ builder, and along the way,
i have written a snake program using javascript.. the problem is that the snake
I have written a program using Free Pascal and the Lazarus IDE. In brief,

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.