TYPO3 API  SVNRelease
class.tx_scheduler_sleeptask.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2009-2011 François Suter <francois@typo3.org>
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *
00017 *  This script is distributed in the hope that it will be useful,
00018 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 *  GNU General Public License for more details.
00021 *
00022 *  This copyright notice MUST APPEAR in all copies of the script!
00023 ***************************************************************/
00024 
00025 /**
00026  * Class "tx_scheduler_SleepTask" provides a task that sleeps for some time
00027  * This is useful for testing parallel executions
00028  *
00029  * @author      François Suter <francois@typo3.org>
00030  * @package     TYPO3
00031  * @subpackage  tx_scheduler
00032  *
00033  * $Id: class.tx_scheduler_sleeptask.php 10120 2011-01-18 20:03:36Z ohader $
00034  */
00035 class tx_scheduler_SleepTask extends tx_scheduler_Task {
00036 
00037     /**
00038      * Number of seconds the task should be sleeping for
00039      *
00040      * @var integer     $sleepTime
00041      */
00042      public $sleepTime = 10;
00043 
00044     /**
00045      * Function executed from the Scheduler.
00046      * Goes to sleep ;-)
00047      *
00048      * @return  void
00049      */
00050     public function execute() {
00051         $time = 10;
00052 
00053         if (!empty($this->sleepTime)) {
00054             $time = $this->sleepTime;
00055         }
00056 
00057         sleep($time);
00058 
00059         return true;
00060     }
00061 
00062     /**
00063      * This method returns the sleep duration as additional information
00064      *
00065      * @return  string  Information to display
00066      */
00067     public function getAdditionalInformation() {
00068         return $GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xml:label.sleepTime') . ': ' . $this->sleepTime;
00069     }
00070 }
00071 
00072 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/scheduler/examples/class.tx_scheduler_sleeptask.php'])) {
00073     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/scheduler/examples/class.tx_scheduler_sleeptask.php']);
00074 }
00075 
00076 ?>