in reply to Scheduling internal functions/processes to run within a program (like cron does programs)

I see two possible ways of approaching this :

First, you use fork(), and spawn off all the periodic children as children who sleep(). This is easy, as long as you don't need elaborate communication between your children.

The other method would be to implement your own version of cooperative multitasking. I've done something like that in Push HTTP Server, but before you embark on anything like this, have a look at POE, which also does this. Before you choose to go down that way, note that you can't allow any long operations unless you can stomach your whole server being non-respondant. This also means that you could want to look a bit at asynchronous IO, as far as your OS supports it (and Perl).

  • Comment on Re: Scheduling internal functions/processes to run within a program (like cron does programs)

Replies are listed 'Best First'.
Re: Re: Scheduling internal functions/processes to run within a program (like cron does programs)
by BMaximus (Chaplain) on May 23, 2001 at 15:06 UTC
    You know. After some mucking around in CPAN's search. I found Schedule::Cron. Which basicaly is exactly what I wanted.

    The moral of this story. Search CPAN first.

    BMaximus

      I'm awfully happy to see you found this on your own. ;-)

      I was getting ready to reply to you with "Check CPAN for Schedule::Cron!"

      All's well that ends well...

      ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      Peter L. Berghold --- Peter@Berghold.Net
      "Those who fail to learn from history are condemned to repeat it."