ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SlowPlusJob.php
Go to the documentation of this file.
1<?php
2
4
5use ILIAS\BackgroundTasks\Implementation\Bucket\BucketMock;
11
13{
14 const SLEEP_SECONDS = 10;
15
16
23 public function __construct()
24 {
25 }
26
27
31 public function getInputTypes()
32 {
33 return [
34 new SingleType(IntegerValue::class),
35 new SingleType(IntegerValue::class),
36 ];
37 }
38
39
43 public function getOutputType()
44 {
45 return new SingleType(IntegerValue::class);
46 }
47
48
55 public function run(array $input, Observer $observer)
56 {
58 $a = $input[0];
60 $b = $input[1];
61
62 sleep(self::SLEEP_SECONDS);
63 $observer->notifyPercentage($this, 20);
64 sleep(self::SLEEP_SECONDS);
65 $observer->notifyPercentage($this, 40);
66 sleep(self::SLEEP_SECONDS);
67 $observer->notifyPercentage($this, 60);
68 sleep(self::SLEEP_SECONDS);
69 $observer->notifyPercentage($this, 80);
70
71 $output = new IntegerValue();
72 $output->setValue($a->getValue() + $b->getValue());
73
74 return $output;
75 }
76
77
82 public function isStateless()
83 {
84 return true;
85 }
86
87
92 {
93 return 2;
94 }
95}
An exception for terminatinating execution or to throw for unit testing.
getExpectedTimeOfTaskInSeconds()
int the amount of seconds this task usually taskes. If your task-duration scales with the the amount ...
Definition: SlowPlusJob.php:91
notifyPercentage(Task $task, $percentage)
You can change the progress of a currently running task.
run(array $input, Observer $observer)