See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 310] [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Abstract class for common properties of scheduled_task and adhoc_task. 19 * 20 * @package core 21 * @category task 22 * @copyright 2013 Damyon Wiese 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 namespace core\task; 26 27 /** 28 * Abstract class for common properties of scheduled_task and adhoc_task. 29 * 30 * @copyright 2013 Damyon Wiese 31 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 32 */ 33 abstract class task_base { 34 35 /** @var \core\lock\lock $lock - The lock controlling this task. */ 36 private $lock = null; 37 38 /** @var \core\lock\lock $cronlock - The lock controlling the entire cron process. */ 39 private $cronlock = null; 40 41 /** @var $string $component - The component this task belongs to. */ 42 private $component = ''; 43 44 /** @var bool $blocking - Does this task block the entire cron process. */ 45 private $blocking = false; 46 47 /** @var int $faildelay - Exponentially increasing fail delay */ 48 private $faildelay = 0; 49 50 /** @var int $nextruntime - When this task is due to run next */ 51 private $nextruntime = 0; 52 53 /** 54 * Set the current lock for this task. 55 * @param \core\lock\lock $lock 56 */ 57 public function set_lock(\core\lock\lock $lock) { 58 $this->lock = $lock; 59 } 60 61 /** 62 * Set the current lock for the entire cron process. 63 * @param \core\lock\lock $lock 64 */ 65 public function set_cron_lock(\core\lock\lock $lock) { 66 $this->cronlock = $lock; 67 } 68 69 /** 70 * Get the current lock for this task. 71 * @return \core\lock\lock 72 */ 73 public function get_lock() { 74 return $this->lock; 75 } 76 77 /** 78 * Get the next run time for this task. 79 * @return int timestamp 80 */ 81 public function get_next_run_time() { 82 return $this->nextruntime; 83 } 84 85 /** 86 * Set the next run time for this task. 87 * @param int $nextruntime 88 */ 89 public function set_next_run_time($nextruntime) { 90 $this->nextruntime = $nextruntime; 91 } 92 93 /** 94 * Get the current lock for the entire cron. 95 * @return \core\lock\lock 96 */ 97 public function get_cron_lock() { 98 return $this->cronlock; 99 } 100 101 /** 102 * Setter for $blocking. 103 * @param bool $blocking 104 */ 105 public function set_blocking($blocking) { 106 $this->blocking = $blocking; 107 } 108 109 /** 110 * Getter for $blocking. 111 * @return bool 112 */ 113 public function is_blocking() { 114 return $this->blocking; 115 } 116 117 /** 118 * Setter for $component. 119 * @param string $component 120 */ 121 public function set_component($component) { 122 $this->component = $component; 123 } 124 125 /** 126 * Getter for $component. 127 * @return string 128 */ 129 public function get_component() { 130 return $this->component; 131 } 132 133 /** 134 * Setter for $faildelay. 135 * @param int $faildelay 136 */ 137 public function set_fail_delay($faildelay) { 138 $this->faildelay = $faildelay; 139 } 140 141 /** 142 * Getter for $faildelay. 143 * @return int 144 */ 145 public function get_fail_delay() { 146 return $this->faildelay; 147 } 148 149 /** 150 * Do the job. 151 * Throw exceptions on errors (the job will be retried). 152 */ 153 public abstract function execute(); 154 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body