ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\BackgroundTasks\Implementation\TaskManager\PersistingObserver Class Reference

Class PersistingObserver. More...

+ Inheritance diagram for ILIAS\BackgroundTasks\Implementation\TaskManager\PersistingObserver:
+ Collaboration diagram for ILIAS\BackgroundTasks\Implementation\TaskManager\PersistingObserver:

Public Member Functions

 __construct (protected Bucket $bucket, protected Persistence $persistence)
 
 notifyState (int $state)
 
 notifyPercentage (Task $task, int $percentage)
 
 notifyCurrentTask (Task $task)
 
 heartbeat ()
 I'm still alive! If your calculation takes a really long time don't forget to use the heartbeat. More...
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Observer
 notifyPercentage (Task $task, int $percentage)
 You can change the progress of a currently running task. More...
 
 notifyCurrentTask (Task $task)
 If the current task changes notify the observer. More...
 

Detailed Description

Class PersistingObserver.

Author
Oskar Truffer ot@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch When notifying something to the bucket this observer also persists the changes into the database.

Definition at line 31 of file PersistingObserver.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\BackgroundTasks\Implementation\TaskManager\PersistingObserver::__construct ( protected Bucket  $bucket,
protected Persistence  $persistence 
)

Definition at line 33 of file PersistingObserver.php.

34  {
35  }

Member Function Documentation

◆ heartbeat()

ILIAS\BackgroundTasks\Implementation\TaskManager\PersistingObserver::heartbeat ( )

I'm still alive! If your calculation takes a really long time don't forget to use the heartbeat.

Otherwise the bucket might be killed while still running. All notify tasks of the observer also trigger a heartbeat.

Implements ILIAS\BackgroundTasks\Observer.

Definition at line 65 of file PersistingObserver.php.

65  : void
66  {
67  $this->bucket->heartbeat();
68  $this->persistence->updateBucket($this->bucket);
69  }

◆ notifyCurrentTask()

ILIAS\BackgroundTasks\Implementation\TaskManager\PersistingObserver::notifyCurrentTask ( Task  $task)

Definition at line 54 of file PersistingObserver.php.

54  : void
55  {
56  $this->bucket->setCurrentTask($task);
57  $this->bucket->heartbeat();
58  $this->persistence->updateBucket($this->bucket);
59  }

◆ notifyPercentage()

ILIAS\BackgroundTasks\Implementation\TaskManager\PersistingObserver::notifyPercentage ( Task  $task,
int  $percentage 
)

Definition at line 47 of file PersistingObserver.php.

47  : void
48  {
49  $this->bucket->setPercentage($task, $percentage);
50  $this->bucket->heartbeat();
51  $this->persistence->updateBucket($this->bucket);
52  }

◆ notifyState()

ILIAS\BackgroundTasks\Implementation\TaskManager\PersistingObserver::notifyState ( int  $state)
Parameters
$stateint

Implements ILIAS\BackgroundTasks\Observer.

Definition at line 40 of file PersistingObserver.php.

40  : void
41  {
42  $this->bucket->setState($state);
43  $this->bucket->heartbeat();
44  $this->persistence->updateBucket($this->bucket);
45  }

The documentation for this class was generated from the following file: