diff options
author | Marcel Klehr <mklehr@gmx.net> | 2023-04-20 13:55:28 +0200 |
---|---|---|
committer | Marcel Klehr <mklehr@gmx.net> | 2023-04-23 12:36:12 +0200 |
commit | 0f3211c4e46492eb90b24af231cd738f989eed3d (patch) | |
tree | 7ece153849db0926111ab670a5d2e069321901c7 /lib/public/BackgroundJob | |
parent | 6f9a3218d02ca857e0ade4658fc371193e91dd52 (diff) | |
download | nextcloud-server-0f3211c4e46492eb90b24af231cd738f989eed3d.tar.gz nextcloud-server-0f3211c4e46492eb90b24af231cd738f989eed3d.zip |
Add IParallelAwareJob interface
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'lib/public/BackgroundJob')
-rw-r--r-- | lib/public/BackgroundJob/IParallelAwareJob.php | 20 | ||||
-rw-r--r-- | lib/public/BackgroundJob/Job.php | 4 |
2 files changed, 22 insertions, 2 deletions
diff --git a/lib/public/BackgroundJob/IParallelAwareJob.php b/lib/public/BackgroundJob/IParallelAwareJob.php new file mode 100644 index 00000000000..9374901e09f --- /dev/null +++ b/lib/public/BackgroundJob/IParallelAwareJob.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; +} diff --git a/lib/public/BackgroundJob/Job.php b/lib/public/BackgroundJob/Job.php index 89ea41381c9..c1e129f1221 100644 --- a/lib/public/BackgroundJob/Job.php +++ b/lib/public/BackgroundJob/Job.php @@ -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; } |