develooper Front page | perl.perl5.porters | Postings from December 2004

Re: [perl #32714] Objects destroyed in the wrong order during global destruction

From:
Elizabeth Mattijsen
Date:
December 3, 2004 07:04
Subject:
Re: [perl #32714] Objects destroyed in the wrong order during global destruction
Message ID:
f0611040dbdd630013960@[192.168.56.3]
At 11:54 AM +0100 12/3/04, Rafael Garcia-Suarez wrote:
>Elizabeth Mattijsen wrote:
>>  Wow.  But is having B as a prerequisite a good idea?
>
>Well, B is core :)

Ah, ok!

Well, I've just uploaded this to CPAN:

=head1 NAME

ogd - ordered global destruction of objects

=head1 SYNOPSIS

  use ogd;

  ogd->register( @object ); # for objects from XSUBs only

=head1 DESCRIPTION

This module adds ordered destruction of object in LIFO order during global
destruction.

=head1 CLASS METHODS

=head2 register

  ogd->register( @object ); # only for blessed objects created in XSUBs

Not all blessed objects in Perl are necessarily created with "bless": they can
also be created in XSUBs and thereby bypass the registration mechanism that
ogd installs for "bless".  For those cases, it is possible to register objects
created in such a manner by calling the "register" class function.  Any object
passed to it will be registered.

=head1 REQUIRED MODULES

  B (any)
  Scalar::Util (any)

=head1 ORDER OF LOADING

The C<ogd> pragma installs its own version of the "bless" system function.
Without that special version of "bless", it can not work (unless you
L<register> your objects yourself).  This means that the C<ogd> pragma
needs to be loaded B<before> any modules that you want the special
functionality of C<ogd> to be applied to.

=head1 TODO

Examples should be added.

=head1 AUTHOR

Elizabeth Mattijsen, <liz@dijkmat.nl>.

Please report bugs to <perlbugs@dijkmat.nl>.

=head1 ACKNOWLEDGEMENTS

Mark Jason Dominus for the initial impetus.  Yitzchak Scott-Thoennes for
the suggestion of using the B module.  Inspired by similar work on
L<Thread::Bless>.

=head1 COPYRIGHT

Copyright (c) 2004 Elizabeth Mattijsen <liz@dijkmat.nl>. All rights
reserved.  This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

=head1 SEE ALSO

L<Thread::Bless>.

=cut

For those who cannot wait: it's also available from:

    http://www.liz.nl/CPAN/ogd-0.01.tar.gz



Liz



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About