ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
SlowPlusJob.php
Go to the documentation of this file.
1 <?php
2 
4 
11 
12 class SlowPlusJob extends AbstractJob
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 
91  {
92  return 2;
93  }
94 }
notifyPercentage(Task $task, $percentage)
You can change the progress of a currently running task.
run(array $input, Observer $observer)
getExpectedTimeOfTaskInSeconds()
int the amount of seconds this task usually taskes. If your task-duration scales with the the amount ...
Definition: SlowPlusJob.php:90
Create styles array
The data for the language used.