in reply to Threading problem with IO::Socket
The caveat is that when you use a class like IO::Socket to manage a process global resource, it uses memory to retain state. This memory is not implicitly shared. Further, the mechanism by which perl locates methods applicable to objects is through the blessing of the object handle which is a memory reference. The problem here is that even if the routines that implement those methods are re-entrent, unless the state represented by the object handle are themselves correctly shared (and are shareable!), then invoking methods across threads is going to give rise to problems. This is why objects are not shareable.
The upshot is, that the main problem of your code lies in the concepts underlying it. Why do you want to share a process global resource between threads? What are you trying to achieve? Whatever it is can probably be achieved, but it would take and understanding of your goals before the 'right' approach to the problem could be discovered.
|
---|