X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fclass_BaseFrameworkSystem.php;h=5237b802b1faedba51b31d9a45f985d39f5aead9;hp=e15af40017603d2c5fddc56df98c467b07eeae18;hb=2644a1716fe8801811a383d13d56f16a3796bc17;hpb=2c0148a84570f1a8343fa6b98a279e903b3e4fa2 diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index e15af400..5237b802 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -83,6 +83,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ private $iteratorInstance = null; + /** + * Instance of the list + */ + private $listInstance = null; + /** * The real class name */ @@ -101,7 +106,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { /*********************** * Exception codes.... * ***********************/ - + // @todo Try to clean these constants up const EXCEPTION_IS_NULL_POINTER = 0x001; const EXCEPTION_IS_NO_OBJECT = 0x002; const EXCEPTION_IS_NO_ARRAY = 0x003; @@ -1118,6 +1123,65 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { 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() + abs($milliSeconds) / 1000; + + // 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; + } + + /** + * Setter for the list instance + * + * @param $listInstance A list of Listable + * @return void + */ + protected final function setListInstance (Listable $listInstance) { + $this->listInstance = $listInstance; + } + + /** + * Getter for the list instance + * + * @return $listInstance A list of Listable + */ + protected final function getListInstance () { + return $this->listInstance; + } } // [EOF]