[Melbourne-pm] Class::Std vs Object::InsideOut

Jacinta Richardson jarich at perltraining.com.au
Thu May 4 17:45:05 PDT 2006


leif.eriksen at hpa.com.au wrote:
> Can you answer the question "the lack of thread-safety in C::S breaks my
> code here" ? If you cant, the lack of thread-safety isnt an issue -
> YAGNI.

The lack of thread-safety in C::S breaks any code which attempts a fork under
Windows.  See the bonus slides in the below pdf for an explanation

	http://dagolden.com/files/whats_all_the_fuss.pdf

Some further details can be found here:

	http://www.perlmonks.org/?node_id=483162

	In particular:

	On a unix derived OS, fork is done using the system fork call, which
	creates a new process with memory allocated as "copy-on-write" .. that
	means that the same memory locations are used for variables until the
	value of the variable is changed ..  That seems to work just fine for
	inside-out objects -- as the reference is preserved ...

	On Win32, however, forking is faked using threads! (c.f. perlfork) So
	fork-safety on Win32 means getting thread-safety as well, which means
	that thread-safety for inside-out objects winds up being rather
	important, as unsuspecting users might wind up forking their way into
	threads without even realizing it and finding all their objects have
	lost their data.

A discussion of some of the issues with inside out objects in general can be
found here:

	http://www.perlmonks.org/?node=Anti-inside-out-object-ism

Having said all of this, I find the interfaces of both Class::Std and
Object::InsideOut to be well designed, and I imagine that using either would be
equally easy.  I can understand Scott's dilema though, because I expect that
*changing* over from one to the other would be quite a hassle - so if thread
safety could become an issue in the future; then using Class::Std now might not
be a good choice.

Finally, this is only really an issue due to the use of the ident method
(refaddr by a different name).  If Scott over-rode ident to use UUIDs instead,
then he could probably have both Class::Std and thread safety.

	J

-- 
   ("`-''-/").___..--''"`-._          |  Jacinta Richardson         |
    `6_ 6  )   `-.  (     ).`-.__.`)  |  Perl Training Australia    |
    (_Y_.)'  ._   )  `._ `. ``-..-'   |      +61 3 9354 6001        |
  _..`--'_..-_/  /--'_.' ,'           | contact at perltraining.com.au |
 (il),-''  (li),'  ((!.-'             |   www.perltraining.com.au   |




More information about the Melbourne-pm mailing list