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

  • Home
  • SEARCH
  • 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 6383971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:42:59+00:00 2026-05-25T02:42:59+00:00

For example having an array or reader threads and one writer thread we can

  • 0

For example having an array or reader threads and one writer thread we can sinc tham like this via shared_mutex and shared_lock this works if we are not dependent on time. But if we want to get all writing operations done inside of certan time frame and if thay are not done stop waiting and start doing something else inside of reader threads. How to do such thing? How to be capable to say from some watcher thread to all readers threads – “hey guys – there wount be any new data from writer in this time frame so go on.”

  • 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-25T02:43:00+00:00Added an answer on May 25, 2026 at 2:43 am

    Use a timed lock.

    boost::shared_mutex  m
    
    Reader()
     shared_lock   lock(m, timeout);
     if(!lock) {
       //I don't have the lock. Don't touch the resource and do something else.
     }
     else {
       //I have the lock. Read now.
     }
    
    Writer()
     upgrade_lock lck(m);
     upgrade_to_unique_lock uniqueLock(lck);
    

    Just pick a timeout value. Note that it won’t necessarily be precise.

    BTW: if you’re going to use Boost.Threads, perhaps you should read the documentation. It’s pretty extensive. I’ve never used Boost.Threads, and it took me a matter of seconds to find this.

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

Sidebar

Related Questions

Here is a (big) example of the massive problem I am having, when this
In symfony 2, one can embed a controller in a template. For example, I
I'm having an array for example with 4 elements array(a, b, c, d); what
I'm having some trouble with this example of creating a transformer lambda with the
I am having an array of integer say int example[5] = {1,2,3,4,5} . Now
I am having problems with an array where I for example want to printout
Might seem like a stupid question, but I'm having an issue creating an array
Getting started with jquery and having trouble getting hello world type example going for
Is having tags inside a jstl tag considered bad form? So for example I
I am having trouble getting my ASP.NET application to start an application. For example

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.