Boost logo

Boost :

From: larsbj_at_[hidden]
Date: 2001-06-12 14:15:32

williamkempf_at_[hidden] writes:

| Actually, Boost.Function is required to get the deferred call
| internally in create_thread(). That is, however, an implementation
| detail. As a user all you need is a binder lib.

Do I...

This work with the code in the previous mail.
It is possible that the binders I use is in reality a defer_call...
but then I really don't see the difference between defer_call and a

This code is very similar to the one I sent you some days ago.

class thread_handle {
        explicit thread_handle(pthread_t p)
                : pth_(p) {}
        void join() {
                pthread_join(pth_, 0);
        pthread_t pth_;

template <typename Functor>
class ThreadArg {
        ThreadArg(Functor const & functor)
        : f_(functor) {}
        static thread_handle execute(Functor const & functor) {
                ThreadArg * arg = new ThreadArg(functor);
                pthread_t pth;
                pthread_create(&pth, 0, ThreadArg::start_routine, arg);
                return thread_handle(pth);
        static void * start_routine(void * arg_v) {
                ThreadArg * arg = static_cast<ThreadArg*>(arg_v);
                delete arg;
        Functor f_;

template <typename Functor>
thread_handle create_thread(Functor const & functor)
        return ThreadArg<Functor>::execute(functor);

| > Is there a binders lib proposed for boost that would allow me to do
| > the above?
| The Lambda Library will allow constructs similar to this, but with a
| richer syntax. I believe there's also a lighter weight binder
| library in the files section.

You wouldn't happen to know its name?


Boost list run by bdawes at, gregod at, cpdaniel at, john at