Le 15/04/12 18:57, Master a écrit :
Hello all again .
i have couple of questions again which i would appreciate any kind of help and answer,
my first question is about packaged_task and how we can use it ,
i mean i tried using packaged_task with functions ,  with parameters , and i got errors doing it . so do we always have to use class or stcucts in order for us to use packaged_task ?
Hi,
The current implementation of packaged_task are nullary, no arguments are allowed.
template<typename R>
class packaged_task {
    // execution
    void operator()();
}
Waiting for

template<class R, class... ArgTypes>
class packaged_task<R(ArgTypes...)> {
  void operator()(ArgTypes... );
}

you will need to use a functor.

how can i send some arguments to a function when im trying to make a package out of ?
Have you tried boost::bind?

can someone show me a simple sample of using Promise in threading ? i mean i already know about future , whats the need for Promise ? !

Promise is the on of the basic class of the Boost.Thread/Futures design. In order to have a future you need a promise, a way to provide a value. packaged_task encapsulates a function with a promise and a future. When the functions ends the result is set on the promise so that you could retrieve it using the associated future.

Bat see http://www.justsoftwaresolutions.co.uk/threading/multithreading-in-c++0x-part-8-futures-and-promises.html for an example.
for  better explanation and a concrete example.

Best,
Vicente