Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add IParallelAwareJob interface
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Apr 23, 2023
commit 0f3211c4e46492eb90b24af231cd738f989eed3d
20 changes: 20 additions & 0 deletions lib/public/BackgroundJob/IParallelAwareJob.php
Original file line number Diff line number Diff line change
@@ -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;
}
4 changes: 2 additions & 2 deletions lib/public/BackgroundJob/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*
* @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;
Expand Down Expand Up @@ -145,7 +145,7 @@ public function getArgument() {
* @return void
* @since 27.0.0
*/
public function setAllowParallelRuns(bool $allow) {
public function setAllowParallelRuns(bool $allow): void {
$this->allowParallelRuns = $allow;
}

Expand Down