1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-02 17:52:14 +01:00
parallel/lib/Sync/Mutex.php

26 lines
664 B
PHP
Raw Normal View History

2016-08-22 06:40:48 +02:00
<?php declare(strict_types = 1);
2016-08-18 18:04:48 +02:00
2016-08-23 23:47:40 +02:00
namespace Amp\Parallel\Sync;
2016-08-18 18:04:48 +02:00
2016-11-15 00:43:44 +01:00
use Interop\Async\Promise;
2015-08-02 03:15:03 +02:00
/**
2015-08-31 19:26:11 +02:00
* A non-blocking synchronization primitive that can be used for mutual exclusion across contexts.
2015-08-02 03:15:03 +02:00
*
* Objects that implement this interface should guarantee that all operations
* are atomic. Implementations do not have to guarantee that acquiring a lock
* is first-come, first serve.
2015-08-02 03:15:03 +02:00
*/
2015-12-05 06:50:32 +01:00
interface Mutex
2015-08-02 03:15:03 +02:00
{
/**
* @coroutine
*
* Acquires a lock on the mutex.
*
2016-11-15 00:43:44 +01:00
* @return \Interop\Async\Promise<\Amp\Parallel\Sync\Lock> Resolves with a lock object when the acquire is
2016-08-18 18:04:48 +02:00
* successful.
2015-08-02 03:15:03 +02:00
*/
2016-11-15 00:43:44 +01:00
public function acquire(): Promise;
2015-08-02 03:15:03 +02:00
}