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

Author Topic: Thread Priority  (Read 8753 times)

0 Members and 1 Guest are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Thread Priority
« Reply #15 on: October 06, 2010, 03:07:35 pm »
Are you sure that this particular piece of code produces the result shown on your screenshot above? I just tried and the SFML thread appears to have a normal priority, as expected.
Laurent Gomila - SFML developer

Contadotempo

  • Full Member
  • ***
  • Posts: 167
  • Firelink Shrine
    • View Profile
Thread Priority
« Reply #16 on: October 06, 2010, 05:31:03 pm »
Quote from: "Laurent"
Are you sure that this particular piece of code produces the result shown on your screenshot above? I just tried and the SFML thread appears to have a normal priority, as expected.

It isn't but the process was the same, I'll post the code as soon as I get home since I don't have the project in this computer.

EDIT @ 4:40pm:
In this computer I have Visual Studio 2010 and I tried compiling the code I posted, and apparently I get normal priority as well. At home I compile with VS2008, that's what I used to compile the original code, thus getting the "lowest priority" issue.
Again, when I get home I'll check this. Could the problem be in VS2008?
I should have tested this before asking...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Thread Priority
« Reply #17 on: October 06, 2010, 05:45:21 pm »
Quote
Could the problem be in VS2008?

No, I've tested with VS 2008.
Laurent Gomila - SFML developer

Contadotempo

  • Full Member
  • ***
  • Posts: 167
  • Firelink Shrine
    • View Profile
Thread Priority
« Reply #18 on: October 06, 2010, 09:44:41 pm »
Oops, I was thinking of the wrong file just then.
This is the original code from the screenshot:

Code: [Select]
#include <SFML/System.hpp>
#include <SFML/Audio.hpp>
#include <iostream>
#include <time.h>

using namespace sf;
using namespace std;

//Thread 1
void play_main_menu(void *UserData)
{

    Music Music;
    Music.OpenFromFile("cistern.ogg");
    Music.Play();
    while (Music.GetStatus() == Music::Playing)
    {
        sf::Sleep(0.1f);
    }
}

//Main function
int main()
{
    int geto;
    srand(time(NULL));
    Clock c1;    
    Thread th1(&play_main_menu);    
    th1.Launch();

    Sleep(1.f);
    while(c1.GetElapsedTime()!=0)
    {
        geto = rand() % 256;
        cout << "Main: Aos "  << c1.GetElapsedTime() << " segundos, o programa gerou: " << geto << endl;
        Sleep(1.f);

    }
    return 0;
}

Now if I try to compile it in VS2008 it doesn't make the thread priority "Lowest" like it did before. Now it makes it "Time Critical". There's definitely something wrong with the settings.

When I compile it in VS2010 it sets it to "normal" like it should.
So I know it's not a problem with SFML, but it's on my side.
I'll try reinstalling VS2008.

Thanks for all the help so far!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Thread Priority
« Reply #19 on: October 06, 2010, 10:55:23 pm »
By the way, musics are already threaded, you don't have to play them in separate threads.
Laurent Gomila - SFML developer

 

anything