in reply to complex iterator needed

That depends... what would you like to do during the function is stopped? Would you just like to give another program to give a chance to get some CPU time? Or would you like to change some of the data that the function is working on?

A. There is not really an easy solution... If you just want to give some other programs some CPU time you could trigger the sleep function every so often.

B. There are two hard solutions... and both include the building of a framework or module.

The first way to make this possible is to have a global variable that is read by the function. Once the variable signals to stop, the function saves all it's data and states and saves them either in memory or to a file. The memory address of the data or the filename are returned once the function is done with. When you want to resume you just point your function to the already processed data and it's states and let it start from there

The second version would be the same idea as above but with a more professional interface: Signals. You would write a module/function with signal traps. If the stop signal is given all data and states are saved. If the resume signal is given all saved data and states are reloaded and the function starts where it stopped.

Summary: It seems that you are in for some development time. You might want to take a look at Thread::Suspend.

/oliver/

Replies are listed 'Best First'.
Re: Re: complex iterator needed
by liz (Monsignor) on Feb 01, 2004 at 23:02 UTC
    You might want to take a look at Thread::Suspend.

    Please note that Thread::Suspend only works on systems on which Thread::Signal works. And that means fewer and fewer Linux systems. ;-(

    I'd welcome any suggestions on getting Thread::Signal to reliably work on more platforms.

    Liz