ILockingProvider.php 2.2 KB

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