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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:50:44+00:00 2026-05-31T23:50:44+00:00

The following code has concurrency issues. Here inDegVec is a global int * ,

  • 0

The following code has concurrency issues. Here inDegVec is a global int *, and getGUID() and getTime() are innocuous accessors for POD variables.

void operator () ( GNode& src,
                      tbb::parallel_do_feeder<GNode>& feed_it )
        const 
{

            std::list<GNode> addNodes;             

            // some thread-safe code that populates addNodes

            while (!addNodes.empty()) {
                feed_it.add(addNodes.front());
                addNodes.pop_front();
            } 

            if (inDegVec[srcAVI->getUID()] == 0) {
                // srcAVI is still the minimum among its neighbors
                if (srcAVI->getTime() < colTime) {
                    //lwl.push (src);
                    //tbb::mutex::scoped_lock lock(histMutex);
                    assert(addNodes.empty());
                    feed_it.add(src);
                }  
           } 


};

If I wrap the while/if blocks in a mutex, the code works. But why is this necessary? Is parallel_do_feeder::add() not thread-safe? The example code I’ve seen (such as http://llpanorama.wordpress.com/2008/03/09/parallel_do-parallel-done/) use no synchronization, suggesting that it is… and I don’t see a discussion of parallel_do_feeder’s thread safety in the TBB manual.

  • 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-31T23:50:45+00:00Added an answer on May 31, 2026 at 11:50 pm

    Yes, parallel_do_feeder is thread safe.

    Is the copy constructor of GNode thread safe? The instance of GNode passed to parallel_do_feeder::add() is copied into a task that will process it (possibly in another thread).

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

Sidebar

Related Questions

The following code has me confused int a=2,b=5,c; c=a+++b; printf(%d,%d,%d,a,b,c); I expected the output
The following code has a simple binding which binds the Text of the TextBlock
I noticed using task manager that the following code has a GDI leak in
I am generating a simple form with php. The following code has been reduced
I have tried the following code but has no effect: Imports system.Runtime.InteropServices <DllImport(UxTheme.DLL, BestFitMapping:=False,
Does anybody know why the following code only has effect in FF? $(document).ready(function() {
My code is in c# asp.net 3.5 In the following code the Msg has
Class 1 has the following code that generates the exception - -(IBAction) searchAllAction: (id)
The documentation has the following code var options = { host: 'www.google.com', port: 80,
The following code executes properly when the data key has no data to send,

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.