SFML community forums

Help => Network => Topic started by: golgoth on November 04, 2010, 03:21:27 am

Title: Threads/Network related!
Post by: golgoth on November 04, 2010, 03:21:27 am
Greetings,

I’m wondering how to pass function parameter to a thread… if that’s is possible:
Code: [Select]

void ThreadServer(void *in_data)
{
}

Bool SFML_Network::ServerStart(const Char *in_name, UShort in_port)
{
sf::Thread l_thread(&ThreadServer, this);

….

Is there an elegant way that in_name and in_port being pass to ThreadServer? Besides making member or global variables.
Title: Threads/Network related!
Post by: tntexplosivesltd on February 14, 2011, 11:55:09 pm
The easiest way to do this is to use the UserData parameter discussed in the thread tutorial (http://www.sfml-dev.org/tutorials/1.6/system-threads.php). Note this is for SFML 1.6, for SFML 2.0 you can use functors (http://en.wikipedia.org/wiki/Function_object) (aka function objects)