ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilAssQuestionProcessLockerFile.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLocker.php';
5 
13 {
14  const PROCESS_NAME_QUESTION_WORKING_STATE_UPDATE = 'questionWorkingStateUpdate';
15 
19  protected $lockFileStorage;
20 
24  protected $lockFileHandles;
25 
30  {
31  $this->lockFileStorage = $lockFileStorage;
32  $this->lockFileHandles = array();
33  }
34 
39  {
40  $this->requestLock(self::PROCESS_NAME_QUESTION_WORKING_STATE_UPDATE);
41  }
42 
47  {
48  $this->releaseLock(self::PROCESS_NAME_QUESTION_WORKING_STATE_UPDATE);
49  }
50 
55  {
56  $this->requestLock(self::PROCESS_NAME_QUESTION_WORKING_STATE_UPDATE);
57  }
58 
63  {
64  $this->releaseLock(self::PROCESS_NAME_QUESTION_WORKING_STATE_UPDATE);
65  }
66 
70  private function requestLock($processName)
71  {
72  $lockFilePath = $this->getLockFilePath($processName);
73  $this->lockFileHandles[$processName] = fopen($lockFilePath, 'w');
74  flock($this->lockFileHandles[$processName], LOCK_EX);
75  }
76 
81  private function getLockFilePath($processName)
82  {
83  $path = $this->lockFileStorage->getPath();
84  return $path . '/' . $processName . '.lock';
85  }
86 
90  private function releaseLock($processName)
91  {
92  flock($this->lockFileHandles[$processName], LOCK_UN);
93  fclose($this->lockFileHandles[$processName]);
94  }
95 }
__construct(ilAssQuestionProcessLockFileStorage $lockFileStorage)
Create styles array
The data for the language used.