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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:43:48+00:00 2026-05-26T05:43:48+00:00

I have a library with an IJobMaker entity that creates a certain amount of

  • 0

I have a library with an IJobMaker entity that creates a certain amount of IJob objects to be run on threads of their own managed by the user.
To track each IJob‘s progress I implement the observer pattern with an IProgressObserver within every job. The difficulty arises when I wish to report on OVERALL progress.

The ideal for me would be to have IProgressOverserver.ReportProgress(float jobProgress, float overallProgress that reports both job and overall progress.IJobMaker can be aware of each job’s portion of the overall work and somehow gather everyone’s reports.

Two main questions arise:

  1. Synchronization mechanism? Keeping a mutex inside IJobMaker for example could harm performance because IProgressOverserver.ReportProgress gets called a lot and a mutex could incur a context switch and what not. InterlockedIncrement looks like a good option but since there’s no such function for floating point, I would be forced to report progress by integer increments. (I’d like to stay away from c++0x features or Boost)

  2. Design pattern? IJob‘s progress is reported from within its deepest algorithms. I need every such a report to both communicate with a central entity for overall progress calculation and call the IProgressObserver.ReportProgress method which resides in IJob.

  • 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-26T05:43:49+00:00Added an answer on May 26, 2026 at 5:43 am

    First of all, it’s quite bad practice to use floats in such cases. Use an integer.

    There is another suggestion. You can use segmentation – synchronise only few threads by one mutex/atomic (one segment). And then collect total among all segments.

    Also, there is good place to start looking around highly parallel algorithms: http://www.1024cores.net/home/lock-free-algorithms

    UDPATE
    There is example of problems with the float

    #include <iostream>
    using namespace std;
    int main() {
        float f = 0;
        for(int i=0; i<100000-98; ++i)
        {
            f += 0.00001;
        }
        cout << f << endl;
    }
    

    So, if you have 100 jobs with 1000 steps each, you will have 1.0 result in 98 earlier than you could expect.

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

Sidebar

Related Questions

I have a library with some objects that I use both from C# and
I have a library A, that I develop. When I deploy it on a
I have a library that I would like to license and distribute. I know
I have a library that interacts with our phone system, ie, Hey phone, call
I have a library written in C that I would like to use in
We have a Library Project that we use for all our central reused code
I have library code that uses ICSharpCode.SharpZipLib under the hood to make it easy
I have a Library ( DLL ) that has a method with the following:
I have a library that I'm trying to get working with rails 3 (specifically
I have a library of common functions that I use in several different projects,

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.