You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.2 KiB

3 years ago
  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. * Interface ILockingProvider
  29. *
  30. * @since 8.1.0
  31. */
  32. interface ILockingProvider {
  33. /**
  34. * @since 8.1.0
  35. */
  36. public const LOCK_SHARED = 1;
  37. /**
  38. * @since 8.1.0
  39. */
  40. public const LOCK_EXCLUSIVE = 2;
  41. /**
  42. * @param string $path
  43. * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
  44. * @return bool
  45. * @since 8.1.0
  46. */
  47. public function isLocked(string $path, int $type): bool;
  48. /**
  49. * @param string $path
  50. * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
  51. * @param string $readablePath human readable path to use in error messages, since 20.0.0
  52. * @throws \OCP\Lock\LockedException
  53. * @since 8.1.0
  54. */
  55. public function acquireLock(string $path, int $type, string $readablePath = null);
  56. /**
  57. * @param string $path
  58. * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
  59. * @since 8.1.0
  60. */
  61. public function releaseLock(string $path, int $type);
  62. /**
  63. * Change the type of an existing lock
  64. *
  65. * @param string $path
  66. * @param int $targetType self::LOCK_SHARED or self::LOCK_EXCLUSIVE
  67. * @throws \OCP\Lock\LockedException
  68. * @since 8.1.0
  69. */
  70. public function changeLock(string $path, int $targetType);
  71. /**
  72. * release all lock acquired by this instance
  73. * @since 8.1.0
  74. */
  75. public function releaseAll();
  76. }