Boost logo

Boost :

Subject: Re: [boost] Futures Review Starts Today - January 5, 2009
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-01-26 17:30:25


Hi,

are lazy futures a kind of function pointer? How is the example from the documentation

    int calculate_the_answer_to_life_the_universe_and_everything(){
        return 42;
    }

    void invoke_lazy_task(jss::packaged_task<int>& task){
        try {
            task();
        } catch(jss::task_already_started&) {}
    }

    int main() {
        jss::packaged_task<int> task(calculate_the_answer_to_life_the_universe_and_everything);
        task.set_wait_callback(invoke_lazy_task);
        jss::unique_future<int> f(task.get_future());
        assert(f.get()==42);
    }

differ from

    int main(){
        function<int()> task(calculate_the_answer_to_life_the_universe_and_everything);
        assert(task()==42);
    }

What I'm missing?

Could you show other use cases for the set_wait_callback function?

Thanks,
Vicente
_____________________
Vicente Juan Botet Escribá


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk