Boost logo

Boost Users :

Subject: [Boost-users] [boost.thread] function call and functor in thread creation: performance
From: Boost lzw (boostlzw_at_[hidden])
Date: 2011-01-21 20:55:43


Hi, everyone,

A new thread can be created using boost thread either from a function or a
functor as the entry point of the new thread, as:

void thread_function();
boost::thread thrd(&function);

class functor
{
public:
         inline void operator()();
};
functor f;
boost::thread thrd(f);

Is there a performance difference between these two?

In an ordinary C++ program, can I claim that calling f() 1000 times gives
better performance than calling thread_function() 1000 times, because the
functor is hinted "inline" even the hint is igored by my compiler? Is f()
the same as a function call in term of performance?

Thanks in advance.

Robert



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net