Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
wake and use the threads, (passing arguments via a share I created earlier?)

The 'normal' thing to do is to have your work threads block reading from a que. Your main thread then instigates the worker to do something by posting something to that queue.

This obviously doesn't fit with every use case, but without knowledge of your use case it is hard to advise?

The problem you describe arises because of the ithreads mechanism of cloning everything currently existing into each newly spawned thread. This is a way of avoiding the problem by avoiding the class(s) giving you problems from being cloned.

There are other approaches, some of which were suggested by anonymonk above--like fixing the module.

One not mentioned so far is to create a 'thread factory thread'. You start a thread early in the program--before loading most other modules--who's sole purpose is to spawn other threads. Because any threads spawned by the factory thread are clones of it, they will not have anything cloned into them that was not loaded when the factory thread was spawned.

The problem with this is that I haven't yet found a way to implement a clean interface for it.

If your croak override works, I'd say go for it. But the whole concept of inside-out (flyweight) objects and threads are pretty incompatible.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^5: Class::Std::Fast cache and threads by BrowserUk
in thread 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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-24 06:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found