public final function getIteratorInstance () {
return $this->iteratorInstance;
}
+
+ /**
+ * "Getter" as a time() replacement but with milliseconds. You should use this
+ * method instead of the encapsulated getimeofday() function.
+ *
+ * @return $milliTime Timestamp with milliseconds
+ */
+ public function getMilliTime () {
+ // Get the time of day as float
+ $milliTime = gettimeofday(true);
+
+ // Return it
+ return $milliTime;
+ }
+
+ /**
+ * Idles (sleeps) for given milliseconds
+ *
+ * @return $hasSlept Wether it goes fine
+ */
+ public function idle ($milliSeconds) {
+ // Sleep is fine by default
+ $hasSlept = true;
+
+ // Idle so long with found function
+ if (function_exists('time_sleep_until')) {
+ // Get current time and add idle time
+ $sleepUntil = $this->getMilliTime() + $milliSeconds;
+
+ // New PHP 5.1.0 function found
+ $hasSlept = time_sleep_until($sleepUntil);
+ } else {
+ // My Sun Station doesn't have that function even with latest PHP
+ // package. :(
+ usleep($milliSeconds * 1000);
+ }
+
+ // Return result
+ return $hasSlept;
+ }
}
// [EOF]