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