schwern/test-more — Issue #232: Make a version of Streamer::Print which can be shared between threads
Author: schwern
Created: 2011-11-20 09:35:00+00:00
State: open
Labels: Bug, Discuss, Test-Builder2, Threads

Perl threads do not support sharing filehandles. All the elements of a shared data structure must be shared. This presents a problem: if we're going to share the TestState and everything in it that includes the Formatter which includes the Streamer which contains a filehandle.

Either Streamer::Print has to put that filehandle outside of itself in a non-shared structure, as suggested here: http://stackoverflow.com/questions/8200159/how-to-share-an-object-which-contains-a-filehandle/8200275#8200275

Or somehow the Streamer is not part of the Formatter. One possibility is to make the Streamer an inside-out object, then all its data can be in unshared structures. Unfortunately thread-safe inside-out objects are difficult in 5.8. http://stackoverflow.com/questions/8200159/how-to-share-an-object-which-contains-a-filehandle/8200621#8200621

It's ok if changes to the Streamer are not reflected across threads. We can just document not to do that. It doesn't work in stable either.