I have a problem cleaning the cache of Class::Std::Fast. Here's my test code, which dies while joining the threads:
package STR; use Class::Std::Fast cache => 1; ## ---------------- ---------------- ---------------- ## package main; use threads; use 5.010; use strict; use warnings; STR->new; # create and immediately throw away. # Now do something completely different with threads: threads->create( sub { sleep 2 && say "thread $_" } ) for 1..4; $_->join for threads->list;
My STR class has caching enabled, which means Class::Std::Fast doesn't really destroy instances of that class, it squirrels them away to be reused next time STR->new is called. This breaks when threads are joined anywhere in the program, even if no STR objects are in scope.

What doesn't work:

That last idea seems the most promising. Class::Std::Fast::_cache_class_ref looks like this:
sub _cache_class_ref () { croak q{you can't call this method in your namespace} if 0 != index caller, 'Class::Std::'; return \%do_cache_class_of; }
Which means that just calling delete Class::Std::Fast::_cache_class_ref()->{STR} works beautifully, if I can only get around the croak!

Another avenue seems to be to dynamically override Class::Std::Fast::DESTROY, but doing this in a way that preserves all the original behaviour except caching would get very complex. Finding out if these behaviours even need to be preserved is even more complex.

Note: I'm not actually using Class::Std::Fast directly, I'm using SOAP::WSDL, which via 5 intermediate steps comes back to Class::Std::Fast. My real code is dying with

DESTROY created new reference to dead object 'SOAP::WSDL::XSD::Typelib::Builtin::string' during global dest +ruction (#1)

Does anyone have any suggestions?


In reply to Class::Std::Fast cache and threads by Boldra

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.