ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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
4require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLocker.php';
5
13{
14 const PROCESS_NAME_PERSIST_WORKING_STATE = 'persistWorkingState';
15
20
25
30 {
31 $this->lockFileStorage = $lockFileStorage;
32 $this->lockFileHandles = array();
33 }
34
36 {
37 $this->requestLock(self::PROCESS_NAME_PERSIST_WORKING_STATE);
38 }
39
41 {
42 $this->releaseLock(self::PROCESS_NAME_PERSIST_WORKING_STATE);
43 }
44
45 private function requestLock($processName)
46 {
47 $lockFilePath = $this->getLockFilePath($processName);
48 $this->lockFileHandles[$processName] = fopen($lockFilePath, 'w');
49 flock($this->lockFileHandles[$processName], LOCK_EX);
50 }
51
52 private function getLockFilePath($processName)
53 {
54 $path = $this->lockFileStorage->getPath();
55 return $path.'/'.$processName.'.lock';
56 }
57
58 private function releaseLock($processName)
59 {
60 flock($this->lockFileHandles[$processName], LOCK_UN);
61 fclose($this->lockFileHandles[$processName]);
62 }
63}
__construct(ilAssQuestionProcessLockFileStorage $lockFileStorage)
$path
Definition: index.php:22