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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:24:41+00:00 2026-05-27T04:24:41+00:00

This is in relation to my previous question: D concurrent writing to buffer Say

  • 0

This is in relation to my previous question: D concurrent writing to buffer

Say you have a piece of code that consists of 2 consecutive code blocks A and B, where B depends on A. This is very common in programming. Both A and B consist of a loop, where each iteration can be run in parallel:

double[] array = [ ... ]; // has N elements

// A
for (int i = 0; i < N; i++)
{
    job1(array[i]); // new task
}

// wait for all job1's to be done

// B
for (int i = 0; i < N; i++)
{
    job2(array[i]); // new task
}

B can only be executed when A is finished. How do I wait till all tasks of A are finished before executing B?

  • 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-27T04:24:41+00:00Added an answer on May 27, 2026 at 4:24 am

    I assume you’re using std.parallelism? I wrote std.parallelism, so I’ll let you in on a design decision. There was actually a join function in some of the betas of std.parallelism. It waited until all tasks were finished and then shut down the task pool. I removed it because I realized it was useless.

    The reason is that if you’re manually creating a set of O(N) task objects to iterate over some range, you’re misusing the library. You should be using a parallel foreach loop instead, which automatically joins before it releases control back to the calling thread. Your example would become:

    foreach(ref elem; parallel(array)) {
        job1(elem); 
    }
    
    foreach(ref elem; parallel(array)) {
        job2(elem);
    }
    

    In this case job1 and job2 should not start a new task because the parallel foreach loop is already using enough tasks to fully utilize all CPU cores.

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

Sidebar

Related Questions

In relation to this question ( Efficient hashCode() implementation ) I have one more
I have this problem decomposing a relation schema into a set of schemas that
In relation to this previous question I am trying to create a batch file
This question has a relation with my previous question, What is the real memory
This question is in relation to a previous question I've asked ... see SQL
This is in relation to a previous question I asked here. Calling replaceAll(\n, <br
In relation to this question on Using OpenGL extensions , what's the purpose of
This is in relation to this question I am hosting this WCF service in
In relation to this stackoverflow question , how would I go about creating my
This is in relation to this question . The proposed answers involve adding a

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.