parallel/lib/Sync/Mutex.php

26 lines
670 B
PHP
Raw Normal View History

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
* 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
{
/**
* @coroutine
*
* 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
}