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
|
2015-08-08 05:45:41 +02:00
|
|
|
* 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
|
|
|
{
|
|
|
|
/**
|
2015-08-10 05:30:11 +02:00
|
|
|
* @coroutine
|
|
|
|
*
|
2015-08-08 05:45:41 +02:00
|
|
|
* 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
|
|
|
}
|