Add IParallelAwareJob interface

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
pull/37835/head
Marcel Klehr 3 years ago
parent 6f9a3218d0
commit 0f3211c4e4
  1. 20
      lib/public/BackgroundJob/IParallelAwareJob.php
  2. 4
      lib/public/BackgroundJob/Job.php

@ -0,0 +1,20 @@
<?php
namespace OCP\BackgroundJob;
interface IParallelAwareJob {
/**
* Set this to false to prevent two Jobs from the same class from running in parallel
*
* @param bool $allow
* @return void
* @since 27.0.0
*/
public function setAllowParallelRuns(bool $allow): void;
/**
* @return bool
* @since 27.0.0
*/
public function getAllowParallelRuns(): bool;
}

@ -38,7 +38,7 @@ use Psr\Log\LoggerInterface;
*
* @since 15.0.0
*/
abstract class Job implements IJob {
abstract class Job implements IJob, IParallelAwareJob {
protected int $id = 0;
protected int $lastRun = 0;
protected $argument;
@ -145,7 +145,7 @@ abstract class Job implements IJob {
* @return void
* @since 27.0.0
*/
public function setAllowParallelRuns(bool $allow) {
public function setAllowParallelRuns(bool $allow): void {
$this->allowParallelRuns = $allow;
}

Loading…
Cancel
Save