3 * Degenerate job that just replaces itself in the queue.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
25 * Degenerate job that just replace itself in the queue.
26 * Useful for lock contention and performance testing.
30 class NullJob
extends Job
{
32 * @param $title Title (can be anything)
33 * @param $params Array: job parameters (lives, usleep)
34 * @param $id Integer: job id
36 function __construct( $title, $params, $id = 0 ) {
37 parent
::__construct( 'null', $title, $params, $id );
38 if ( !isset( $this->params
['lives'] ) ) {
39 $this->params
['lives'] = 1;
41 if ( !isset( $this->params
['usleep'] ) ) {
42 $this->params
['usleep'] = 0;
46 public function run() {
47 if ( $this->params
['usleep'] > 0 ) {
48 usleep( $this->params
['usleep'] );
50 if ( $this->params
['lives'] > 1 ) {
51 $params = $this->params
;
53 $job = new self( $this->title
, $params );