ILockingProvider.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. *
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. namespace OCP\Lock;
  26. /**
  27. * Interface ILockingProvider
  28. *
  29. * @package OCP\Lock
  30. * @since 8.1.0
  31. */
  32. interface ILockingProvider {
  33. /**
  34. * @since 8.1.0
  35. */
  36. const LOCK_SHARED = 1;
  37. /**
  38. * @since 8.1.0
  39. */
  40. 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. * @throws \OCP\Lock\LockedException
  52. * @since 8.1.0
  53. */
  54. public function acquireLock(string $path, int $type);
  55. /**
  56. * @param string $path
  57. * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
  58. * @since 8.1.0
  59. */
  60. public function releaseLock(string $path, int $type);
  61. /**
  62. * Change the type of an existing lock
  63. *
  64. * @param string $path
  65. * @param int $targetType self::LOCK_SHARED or self::LOCK_EXCLUSIVE
  66. * @throws \OCP\Lock\LockedException
  67. * @since 8.1.0
  68. */
  69. public function changeLock(string $path, int $targetType);
  70. /**
  71. * release all lock acquired by this instance
  72. * @since 8.1.0
  73. */
  74. public function releaseAll();
  75. }