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

Author Topic: Help in threads  (Read 4701 times)

0 Members and 1 Guest are viewing this topic.

theonekamisama

  • Newbie
  • *
  • Posts: 8
    • View Profile
Help in threads
« on: April 16, 2017, 02:53:45 pm »
this had got to be one of the toughest things in sfml, and i have a doubt..

1) Do threads only work with void functions. what if i want to return someting after the thread is completed.
2) How do you do the thing where you pose code in forums?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Help in threads
« Reply #1 on: April 16, 2017, 03:29:15 pm »
See the official tutorial.

You can post code by using [code=cpp][/code] tags.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

sjaustirni

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
Re: Help in threads
« Reply #2 on: April 16, 2017, 06:10:02 pm »
If you have a decent compiler (i.e. one that supports C++11 features), I suggest you to forget about sf::Thread and start using std::thread. sf::Thread is most likely going away in SFML 3 anyway and your knowledge of std::thread you can reuse in myriad of other projects you may be a part of later on.

In fact, I have just realised this is mentioned in the official docs, but I'm keeping it here anyway. :)