Boost logo

Boost :

From: larsbj_at_[hidden]
Date: 2001-06-13 03:22:26


Douglas Gregor <gregod_at_[hidden]> writes:

| In the above case, using defer_call would be a mistake because it is
| going to
| require the overhead of a virtual call and prohibit what otherwise could be
| inlined _very_ well.

mmm... My main reason for trying out the defer_call has to do with
thread creation (shown), and also with defering calls to be executed
in another thread (I forgot to mention that):

void some_foo(locked_queue<defer_holder> & que)
{
        while (true) {
                defer_holder dh = que.pop();
                (*dh)();
        }
}

void bar() {
        ...
}

int main() {
        locked_queue<defer_holder> queue;
        thread_handle th = create_thread(&some_foo, queue);
        defer_holder dh = defer_call(&bar);
        queue.push(dh);
        ...
}
        

So the boost::function<> or the object returned from bind need to be
packaged somehow to be able to pass it through a queue.

So perhaps a "defer_call" that packages function objects with
operator()() would be more suitable for Boost.Thread or boost in
general?

-- 
	Lgb

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