Page 1 of 1

Threads & Strings - clarification/ ideas

Posted: Thu Nov 06, 2003 3:37 pm
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?

Re: Threads & Strings - clarification/ ideas

Posted: Thu Nov 06, 2003 5:51 pm
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 :)

Re: Threads & Strings - clarification/ ideas

Posted: Thu Nov 06, 2003 6:05 pm
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.

Posted: Thu Nov 06, 2003 6:11 pm
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.