1
0

ILockingProvider.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. *
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. namespace OCP\Lock;
  25. /**
  26. * Interface ILockingProvider
  27. *
  28. * @package OCP\Lock
  29. * @since 8.1.0
  30. */
  31. interface ILockingProvider {
  32. /**
  33. * @since 8.1.0
  34. */
  35. const LOCK_SHARED = 1;
  36. /**
  37. * @since 8.1.0
  38. */
  39. const LOCK_EXCLUSIVE = 2;
  40. /**
  41. * @param string $path
  42. * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
  43. * @return bool
  44. * @since 8.1.0
  45. */
  46. public function isLocked(string $path, int $type): bool;
  47. /**
  48. * @param string $path
  49. * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
  50. * @throws \OCP\Lock\LockedException
  51. * @since 8.1.0
  52. */
  53. public function acquireLock(string $path, int $type);
  54. /**
  55. * @param string $path
  56. * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
  57. * @since 8.1.0
  58. */
  59. public function releaseLock(string $path, int $type);
  60. /**
  61. * Change the type of an existing lock
  62. *
  63. * @param string $path
  64. * @param int $targetType self::LOCK_SHARED or self::LOCK_EXCLUSIVE
  65. * @throws \OCP\Lock\LockedException
  66. * @since 8.1.0
  67. */
  68. public function changeLock(string $path, int $targetType);
  69. /**
  70. * release all lock acquired by this instance
  71. * @since 8.1.0
  72. */
  73. public function releaseAll();
  74. }