I am attempting to call a private member function (should not be available as public or protected) as a worker item with the Win32 function QueueUserWorkItem()
. I know I've done this before and it was easy, but now I can't find that snippet, nor can I make bind()
voodoo work. So for the purposes of this question the class is:
class Arbitrary {
public:
Arbitrary() ;
~Arbitrary() ;
bool UsefulPublicFunction(unsigned uParameter) ;
protected:
private:
void PrivateWorkItem(void* pVoid) ;
} ;
And inside UsefulPublicFunction()
we might see:
LPTHREAD_START_ROUTINE pThreadStartRoutine ;
ULONG uFlags = 0 ;
void* pContext = nullptr ;
if (QueueUserWorkItem(pThreadStartRoutine, pContext, uFlags)) {
//blah blah blah
}
Where I seem to go off in the weeds is with the assignment to pThreadStartRoutine
with something like:
pThreadStartRoutine = std::bind<&Arbitrary::PrivateWorkItem, this, std::placeholders::_1> ;
I recognize that the signature for PrivateWorkItem
probably should change to:
private:
DWORD WINAPI PrivateWorkItem(void* pVoid) ;
Even with that change, no joy. VS2015 really hates the way I'm using bind()
.
What should my assignment to pThreadStartRoutine
look like?