Jump to content
  • Advertisement
Sign in to follow this  
Dead_Zone

i need a bit of help

This topic is 3907 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello, im building a server, im using a pre-made socket management system, im having a problem with integration, specifically with threads the only way im able to get this to compile is if its static, but i dont want static members, i'll show my error below..hopefully someone can help me compile it myThread::myThread(LPTHREAD_START_ROUTINE,LPVOID,DWORD,DWORD,BOOL) thats that args for the constructor of the class, and here are my errors 1>.\Infoserver.cpp(108) : error C3867: 'InfoServer::serverHandleThread': function call missing argument list; use '&InfoServer::serverHandleThread' to create a pointer to member 1>.\Infoserver.cpp(265) : error C3867: 'InfoServer::clientHandleThread': function call missing argument list; use '&InfoServer::clientHandleThread' to create a pointer to member ^ however doing the suggested above does not work =\

Share this post


Link to post
Share on other sites
Advertisement
If LPTHREAD_START_ROUTINE is a function pointer you're passing to CreateThread, the function must be a static function if it's a member function of a class. That is because you can't use C++ member function pointers like old-fashion C-style function pointers, since a C++ member function has a hidden "this" parameter that tells the function which class instance to operate on.

The common way to handle this situation is to have a static member function that serves as a proxy, and send a pointer to the class instance to the CreateThread function. Then the static function uses the pointer to call some other regular function. With this sort of setup it's usually easier to implement by having a class inherit from the a generic thread class and override a virtual function that gets called by the thread.

As an alternative, you could send your thread class a pointer to a member function using boost::bind and boost:function. The thread class could then handle the proxy stuff, and call the member specified member function.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!