At the moment I am storing a function call via the function MyClass::Enable that I've presented below. It's generic in the sense that I can later play the function back on a consumer thread by looping through the commanList and not have to provide any function arguments.
However through a quick performance check this method takes 2x longer in processing time to complete the stored function when compared to using a function lookup table (which breaks the generic part) and storing the function arguments as well as the function lookup position. (apologies if this does not make sense : its essentially a function recorder).
Is there a more performance friendly version of std::tr1::bind [boost::bind], or is there a better way of recording a function call in a generic manner and playing it back later ?
class CVertexFormatGLPtr
{
void Enable(size_t a, size_t b);
void Disable();
};
class MyClass
{
public:
typedef std::function<void ()> command;
typedef std::list<command> commandList;
// This is a typedef of CVertexFormatPtr & CVertexFormatGLPtr
VertexFormatMap& m_vertexFormats;
void Enable(const CVertexFormatPtr& pVFormat, size_t a, size_t b)
{
// search to find if vertex buffer is active
auto itor = m_vertexFormats.find(pVFormat);
CVertexFormatGLPtr pVFormatGL = CVertexFormatGLPtr();
if ( itor != m_vertexFormats.end() )
{
pVFormatGL = (*itor).second;
}
std::function<void()> zeroArg = std::bind(&CVertexFormatGL::Enable, pVFormatGL, a, b);
m_renderCommands.push_back(zeroArg);
}
};