Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Threads/Network related!  (Read 1970 times)

0 Members and 1 Guest are viewing this topic.

golgoth

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Threads/Network related!
« 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.

tntexplosivesltd

  • Full Member
  • ***
  • Posts: 163
    • View Profile
Threads/Network related!
« Reply #1 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. Note this is for SFML 1.6, for SFML 2.0 you can use functors (aka function objects)