2015-08-02 03:15:03 +02:00
|
|
|
<?php
|
|
|
|
namespace Icicle\Concurrent\Sync;
|
|
|
|
|
|
|
|
/**
|
2015-08-08 05:45:41 +02:00
|
|
|
* A simple mutex that provides asynchronous, atomic locking and unlocking across
|
2015-08-02 03:15:03 +02:00
|
|
|
* contexts.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
*/
|
|
|
|
interface MutexInterface
|
|
|
|
{
|
|
|
|
/**
|
2015-08-10 05:30:11 +02:00
|
|
|
* @coroutine
|
|
|
|
*
|
2015-08-08 05:45:41 +02:00
|
|
|
* Acquires a lock on the mutex.
|
|
|
|
*
|
|
|
|
* @return \Generator Resolves with a lock object when the acquire is successful.
|
2015-08-10 05:30:11 +02:00
|
|
|
*
|
|
|
|
* @resolve \Icicle\Concurrent\Sync\Lock
|
2015-08-02 03:15:03 +02:00
|
|
|
*/
|
2015-08-08 05:45:41 +02:00
|
|
|
public function acquire();
|
2015-08-02 03:15:03 +02:00
|
|
|
}
|