Skip to content

Commit

Permalink
Comment on sub-second accuracy requiring Time::HiRes::time(). Based o…
Browse files Browse the repository at this point in the history
…n a discussion with and test case from Sjors Gielen.
  • Loading branch information
rcaputo committed Jan 22, 2008
1 parent 3ccb5ef commit 7057981
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/POE/Filter.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ sub clone {
$buf, # BUFFER
@$self[1..$#$self], # everything else
], ref $self;
return $nself;
return $nself;
}

#------------------------------------------------------------------------------
Expand Down
11 changes: 10 additions & 1 deletion lib/POE/Kernel.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3173,12 +3173,21 @@ new one.
EPOCH_TIME is the UNIX epoch time. You know, seconds since midnight,
1970-01-01. "Now" is whatever time() returns, either the built-in or
L<Time::HiRes|Time::HiRes> version.
L<Time::HiRes|Time::HiRes> version. POE will use Time::HiRes if it's
available.
POE supports fractional seconds, but accuracy falls off steeply after
1/100 second. Mileage will vary depending on your CPU speed and your
OS time resolution.
Be sure to use Time::HiRes::time() rather than Perl's built-in time()
if sub-second accuracy matters at all. The built-in time() returns
floor(Time::HiRes::time()), which is nearly always some fraction of a
second in the past. For example the high-resolution time might be
1200941422.89996. At that same instant, time() would be 1200941422.
An alarm for time() + 0.5 would be 0.39996 seconds in the past, so it
would be dispatched immediately (if not sooner).
POE's event queue is time-ordered, so a timer due before time() will
be delivered ahead of other events but not before timers with even
earlier due times. Therefore an alarm() with an EPOCH_TIME before
Expand Down

0 comments on commit 7057981

Please sign in to comment.