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

Author Topic: sf::Thread being used in class functions. [SFML 2.1]  (Read 1349 times)

0 Members and 1 Guest are viewing this topic.

Honorabl3

  • Newbie
  • *
  • Posts: 9
    • View Profile
sf::Thread being used in class functions. [SFML 2.1]
« on: September 30, 2013, 07:17:51 pm »
I'm on my phone to type this, but I wanted to see if there was a solution to my problem. I won't be going into too much depth unless really absoluty needed. Anyway I'll hop into the issue.

It seems when I tell a thread to run from a class method, it won't work.
Code: [Select]
void player::blah()
{
     sf::Thread thread(&rawr, sf::Vector2f(6, 5));
     thread.launch();
}

void player::rawr(sf::Vector2f dir)
{
      //rawr stuff
}

P.S. I have read the thread documentation. It hasn't helped.

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: sf::Thread being used in class functions. [SFML 2.1]
« Reply #1 on: September 30, 2013, 07:39:19 pm »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11029
    • View Profile
    • development blog
    • Email
AW: sf::Thread being used in class functions. [SFML 2.1]
« Reply #2 on: September 30, 2013, 08:26:43 pm »
Yep read the last paragraph "again". The thread goes out of scope, thus gets destroyed and join is called in the destructor. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Honorabl3

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: sf::Thread being used in class functions. [SFML 2.1]
« Reply #3 on: September 30, 2013, 09:38:32 pm »
Well, that seems to be the answer to my three day problem I've been having. Once I get home I'll test it.

 

anything