|Perl Monk, Perl Meditation|
Unload ithreadby rodd (Beadle)
|on Jul 24, 2008 at 17:16 UTC||Need Help??|
rodd has asked for the wisdom of the Perl Monks concerning the following question:
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:
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