Threads & Strings - clarification/ ideas

Everything else that doesn't fall into one of the other PB categories.
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Threads & Strings - clarification/ ideas

Post by dmoc »

- Under what conditions are strings thread safe? Or, if it's easier...
- Under what conditions are strings NOT thread safe?
- Will strings be thread safe the next release?
- Could the next version of PB at least have a semaphore on which threads could wait and/or a (defined) critical section facility?
- Has anyone had success using critical sections with multiple threads? (re string of course)

I know tinman provided some code but I'd prefer an integrated solution, or at least a cleaner solution (no offence intented to tinman :D )

PS: Is the Linux version supported anymore and if so when is the next version expected?
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: Threads & Strings - clarification/ ideas

Post by GPI »

>- Under what conditions are strings thread safe? Or, if it's easier...

when you don't use the same string in diffrent threads.

>- Under what conditions are strings NOT thread safe?

When you use the same string in diffrent threads :)
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Re: Threads & Strings - clarification/ ideas

Post by Pupil »

GPI wrote:>- Under what conditions are strings thread safe? Or, if it's easier...

when you don't use the same string in diffrent threads.

>- Under what conditions are strings NOT thread safe?

When you use the same string in diffrent threads :)
Actually this is not true...

Strings are only safe to use when you know that only one thread is using strings or when you know that only the main process is using strings and not any other thread, this is because of the internal string buffer that all(most of them) PB string commands use. For strings to be thread safe you would, with the current string implementation, need one string buffer for each thread.
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

Ah, ok, it makes sense to me now. The thead reason must be the reason why we have a bad networkserver feature. IE, non-iocp.
Post Reply