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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - lukeescude

Pages: [1]
1
General / My thread isn't running
« on: January 21, 2012, 06:23:07 pm »
Yeah, for some reason, even outside in the main() method, only 1 thread can be created, and the main application stops execution - the thread is being treated like a normal function.

EDIT: Never mind, I essentially re-created the issue I started with. Figured it out now. Thanks a ton!

Do you know if it's possible to store threads in an array?

2
General / My thread isn't running
« on: January 21, 2012, 06:09:45 pm »
Since each new connection to the server is treated as a separate thread, the thread is instantiated within the function that detects for new connections. I'm not sure how I'd go about declaring the thread outside the scope, then using it later on.

3
General / My thread isn't running
« on: January 21, 2012, 05:34:47 pm »
The current version, 1.6

I didn't think of that. I've changed it to make a thread from the sendUsers() function, instead of using the thread as a base class, and it works, but it doesn't execute as a thread, it executes as a normal function.

I wrote a separate program to test, and it worked just fine. So I think what you said about it being destroyed as soon as it was created is what the problem is - How would I counteract this? Make the thread instance outside the program scope?

4
General / My thread isn't running
« on: January 21, 2012, 04:03:05 pm »
@Laurent - That's the problem with a project like this: It's a server, so if I give you "minimal code" it'll just not run. It needs all components to run.

@Posva - I'll check and see if that code works.

EDIT: No instance of constructor "sf::Thread::Thread" matches the argument list

EDIT2: Here, I've cut down the server... http://www.lukeescude.com/serverc.zip

EDIT3: Alright, instead of using sf::Thread as a base class, I've gone back to using threads from functions.

The function launches, but not as a separate thread.

5
General / My thread isn't running
« on: January 21, 2012, 03:36:46 pm »
Here's the ZIP of the entire project:

http://www.lukeescude.com/serverc.zip

This is my first program in C++, so please excuse the terrible coding.

Line 609 of CPP.cpp (the main program file) is where the thread should be launching.

SendUserlist.h contains the outline of the thread code.

EDIT: I wrote a separate program using SFML threads and it worked perfectly, so there's something in my server code that's interfering with the thread creation.

6
General / My thread isn't running
« on: January 21, 2012, 04:39:12 am »
Hey all, I'm new here, and pretty new to multithreading.

I'm using SFML threads as a class, and here's the class code:
Code: [Select]
class SendUsers : public sf::Thread
{
public:
double sock;
private:
    virtual void Run()
    {
        // Print something...
        cout << "Cheers" << endl;
    }
};


And here's where the thread is SUPPOSED to start:
Code: [Select]
SendUsers t;
t.sock=Players[i].Sock; //Players[i].Sock is a double
t.Launch();


But the thread isn't launching/running at all, not sure what to do.

Thanks in advance!

Pages: [1]
anything