Hi Monks,

I'm looking for a way to pause a perl 5.8.8 interpreter thread and later restore it at the same (or next) line in the thread script. And with the same var namespace. By "later" I mean that the perl interpreter may have to be stopped, then restarted next day. So the thread state should be stored in the filesystem.

The reason for this is that I'm working on a perl server daemon that launches threads that do things for users. Now I want to give my users the possibility to "pause" their corresponding thread, go on vacation, and let the thread continue when their are back, without having to worry about server crashes while they're gone.

I've spent the day reading into Data::Dumper and its serializers, PadWalker, __LINE__, eval and goto's, and I think a combination of all these may give me a "homegrown" solution. But it seems quite painful to turn all local and global vars into evalable code, then restore it later and goto to where it stopped. (I have no eval security concerns, as this is all private code).

The sam'ol perl developer dilemma... Am I reinventing the wheel here? Any better packages around cpan to do the job better?

In a perfect world:

use threads; ... sub mythread { ... threads->self->unload("/threadfile.id") if($goaway); ## I'm back. Keep going... } sub laterdaemon { threads->reload("/threadfile.id"); }
cheers
Rod

	The blood red ran from the Grey Monk's side,
	His hands and feet were wounded wide,
	His body bent, his arms and knees
	Like to the roots of ancient trees.
	--William Blake

In reply to Unload ithread by rodd

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.