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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:24:35+00:00 2026-05-11T16:24:35+00:00

I have a function which needs to be invoked with a different number of

  • 0

I have a function which needs to be invoked with a different number of threads each time (am doing some performance calculation, so need to know when the performance starts deteriorating). Example is given below:

getTime() {
    return 0;
}

int main() {
    boost::threadpool::thread_pool<> threads(nThreads);

    for(int j = 0; j <= nLines; j++){
        threads.schedule(boost::bind(&getTime, nThreads, 1));
    }

    threads.wait();
}

Where,
nThreads: A value given at the command line

My question is, would this give me the desired result, as to would this call the ‘getTime’ function with ‘nThreads’ each time the for loop is accessed by the program? Or do I need some other method to find out the same?

what i really want to do is this:

boost::threadpool::thread_pool<> threads(nThreads); 
// start a new thread that calls the "getTime" function 
for(int j = 0; j <= nLines; j++){ 
    //threads.schedule(boost::bind(&getTime, nThreads, 1));
    threads.schedule(boost::bind(&getTime, 0, nLines, pc)); 
}

(not sure which of the above is correct.)

the getTime() function is to be run with a specified number of lines which i get from a text file and give each line to a api, whose performance i wish to calculate. but this is unrelated to the question i have.

i wish to call a function with different number of threads each time and calculate how much time it took each thread to finish. what was the total time taken with 1 thread, what was the total time taken by 2 threads to finish, etc.

  • 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-11T16:24:35+00:00Added an answer on May 11, 2026 at 4:24 pm

    If i understand correctly, what you really want to do is something like this :

    int main() 
    {
        int nbThreads = 20;
        boost::threadpool::thread_pool<> threads(nbThreads);
    
        for(int threadId = 0; threadId <= nbThreads ; ++threadId)
        {
            threads.schedule(getTime);
        }
        threads.wait();  
    }
    

    If i am right, you don’t need to use boost::bind here.

    Note that Boost.ThreadPool is not part of Boost (yet? it ). It will be reviewed, but no review date has been planned yet.

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

Sidebar

Related Questions

I have an application in VC++ which needs to execute a function provided to
I have an if statement that needs to look like this: UPDATE $(input#textbox).keypress(function(e){ key==e.which;
I have the following jQuery which I need adapting: $(document).ready(function(){ $(.rss-popup a).hover(function() { $(this).next(em).stop(true,
I have a function which parses one string into two strings. In C# I
I have a function which searches an STL container then returns the iterator when
I have an function which decodes the encoded base64 data in binary data but
I have a function which gets a key from the user and generates a
i have a function which retrieves values from a webservice , then loops through
I have a function which accepts a string parameter such as: var1=val1 var2=val2 var3='a
I have a function which returns a one-sided intersection of values between two input

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.