U++ framework
Do not panic. Ask here before giving up.

Home » Developing U++ » UppHub » Job package: A lightweight worker thread for non-blocking operations. (A)
Re: RE: Job package: A scope-bound worker thread for non-blocking operations. [message #48783 is a reply to message #48782] Mon, 18 September 2017 08:29 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1264
Registered: August 2007
Senior Contributor
Quote:
That's intereseting, because I actually suggested adding future/promise to U++ facilities... Smile

Anyway, I might check it, but I do not see any archive / link posted.

Mirek


Laughing That can also be done, I can work on it separately, or re-introduce it as an option if you think it is worth it. (In it's current state Job package does not cover a shared_future alternative. Maybe I should consider adding a SharedJob class, but 1) there is already CoWork for paralellization, 2) I don't quite know a real life scenario where it would be more useful than CoWork.)


Nevertheless, recently I've found my "reference based" approach much more performant and convenient than future/promise.

Consider this (pseudo) code:

    double sum_total = 0;
    Job<Vector<double>> job;
    job.Start(DoSomeHeavyCalculationAndFillTheVector);

    //....

    if(job.IsFinishe() && !job.IsError()) {
       for(auto& e : ~job)          // Reference access to Vector. Data is not copied or moved. Vector is filled via a direct -yet safe- access.
             sum_total += e;        // And retrieved in same fashion as well. Note also that there is no requirement for the data type to be contained.
                                    // In fact, using One or Any, or Value, we can even differentiate between the job 
                                    // results for given operations in a single Job easily. :)
    }




Package's link is on the bottom of the first post of this topic.


Best regards,
Oblivion


[Updated on: Mon, 18 September 2017 11:49]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Added SysExec package
Next Topic: firebird: CharSet
Goto Forum:
  


Current Time: Sat Apr 25 19:19:05 GMT+2 2026

Total time taken to generate the page: 0.00799 seconds