in reply to yet another thread question: is Symbol::gensym threadsafe?
To the best of my knowledge, IO::Socket::INET and all it's dependencies are thread-safe. I've written and tested several dozen threaded scripts using them and never encountered a problem that I haven't tracked down to elsewhere.
However, looking at the extract you posted which I've never had occasion to look at before, I'm not particularly impressed, and I do see a possible source of conflict/error.
If Symbol is loaded, as it normally will be, before the threads are spawned, then the package global $genseq will be cloned into each thread that is created. That means that each thread will have it's own sequence counter and will therefore be generating duplicate fully-qualified names for the globs it creates. That shouldn't be a problem as best I can tell as each sequence would live in a separate interpreter and should never come into conflict. But still it tweaks my radar.
It seems to me that it would be better to forgo the naming of the globs completely and just return the address of an anonymous glob created by localising a single well-known name:
sub gensym { return \do{ local *GLOB; *GLOB }; }
You could try temporarily substituting that for the code you posted and see if it makes any difference, but I seriously doubt it will. You've rather glossed over where I think the problem really lies. Ie.
the caching process simply doesn't receive any data at all - which i tried to bypass by locally undef'ing $/ and $\, and although i rather consider this as magic it apparently works - apart from that, sometimes the data get merged in ways that are plainly impossible. for instance chunks of data from one entity seem to appear somewhere else, where they don't belong to.
In particular, the caching process cannot be the reason for these mistakes,... smacks greatly of "famous last words".
I think if you posted (preferably cut down) working code that demonstrates how your caching process works, and resolved the problems described in the above paragraph, then you'd probably fix the overall problem also. I always, always suspect "magic" code :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: yet another thread question: is Symbol::gensym threadsafe?
by grinder (Bishop) on Oct 24, 2007 at 07:19 UTC | |
by BrowserUk (Patriarch) on Oct 24, 2007 at 15:36 UTC | |
by tye (Sage) on Oct 24, 2007 at 16:13 UTC | |
by BrowserUk (Patriarch) on Oct 24, 2007 at 16:32 UTC | |
by ikegami (Patriarch) on Oct 24, 2007 at 17:03 UTC | |
|
Re^2: yet another thread question: is Symbol::gensym threadsafe?
by TOD (Friar) on Oct 24, 2007 at 09:48 UTC | |
by BrowserUk (Patriarch) on Oct 24, 2007 at 15:28 UTC | |
by TOD (Friar) on Oct 25, 2007 at 05:26 UTC |