in reply to Awake from sleep()

I'm familiar with Win32, and the Sleep API function allows optional "defered procedure calls" which are queued and then triggered during sleep; this also wakes it from sleep when done.

I think in principle though sleep is not the right primitive. You want a wait-on-event with an additional timeout. In Win32, I'd use an Event Flag for this. I'm sure any modern OS has a selection of mechanisms like this to choose from.

How to do it portably in Perl? How about a socket? Sleeper does a blocking read on a socket, and signaler writes a byte to signal.

—John

Replies are listed 'Best First'.
Re: Re: Awake from sleep()
by cmilfo (Hermit) on Nov 04, 2002 at 22:57 UTC

    Sounds like the socket solution might work. I mentioned below (in another reply) that the code needs to be platform independent. Is this possible with a socket? And, do you think adding socket communication would be overkill?

    until ($time_to_die) { # listen on socket for N seconds # check files, client, etc }
      How about a pm module that provides for simple blocking event flags. It can contain platform-specific code for known cases, and sockets for all else. That's like File::Copy, which uses native primitives in those cases where it can, and does it itself if it must or doesn't know of a better way.