Thread questions

I have a server-app that creates a new thread for each client that connects.
Every client sends a struct with its own info. The server store these
structs in an array and sends all these structs back to every client.

My questions is: Do I need to lock these structs when I’m writing to/reading
from them? If yes, how to do it?

“Pontus Marktr?m” wrote:

I have a server-app that creates a new thread for each client that connects.
Every client sends a struct with its own info. The server store these
structs in an array and sends all these structs back to every client.

My questions is: Do I need to lock these structs when I’m writing to/reading
from them? If yes, how to do it?

Are you aware that this is totally off topic from SDL ???

Yes you must lock them. Much fun !!!

Newsgroups: loki.open-source.sdl

“Pontus Marktr?m” wrote:

I have a server-app that creates a new thread for each client that
connects.

Every client sends a struct with its own info. The server store these
structs in an array and sends all these structs back to every client.

My questions is: Do I need to lock these structs when I’m writing
to/reading

from them? If yes, how to do it?

Are you aware that this is totally off topic from SDL ???

Yes you must lock them. Much fun !!!

This answer will really help him. :frowning:
BTW, it isn’t totally off topic.

Please consult the SDL documentation.
Read about SDL threads.
Especially look for SDL_CreateMutex().

It would take to much to explain threading here.
I think this could be a starting point. :wink:

Alexander Pipelka
Lead Programmer - BMS Austria
Checkout our OpenSource-Project "ParaGUI"
http://www.bms-austria.com/projects/paragui

----- Original Message -----
From: sdl-news@lokigames.com ()
To:
Sent: Tuesday, October 17, 2000 2:10 PM
Subject: [SDL] Re: thread questions

Please consult the SDL documentation.
Read about SDL threads.
Especially look for SDL_CreateMutex().

There is not so much info in the docs…

It would take to much to explain threading here.
I think this could be a starting point. :wink:

Thanks!

Speaking of threads…

Does SDL use a thread-safe library? What about smpeg? I’ve been having loads
of internal threading problems with a smpeg <-> SDL app. BTW, can I ask about
smpeg here?

Speaking of threads…

Does SDL use a thread-safe library?

Some parts of it are, some aren’t. The event queue is thread-safe,
but most of the video functions are not.

What about smpeg? I’ve been having loads
of internal threading problems with a smpeg <-> SDL app. BTW, can I ask about
smpeg here?

Generally, you should send your smpeg questions to smpeg at lokigames.com

Feel free to post questions relating to SDL/SMPEG threads here though.

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software