2015-07-16 01:12:18 +02:00
|
|
|
<?php
|
|
|
|
namespace Icicle\Concurrent;
|
|
|
|
|
|
|
|
/**
|
2015-08-31 11:19:49 +02:00
|
|
|
* An object that can be synchronized for exclusive access across contexts.
|
2015-07-16 01:12:18 +02:00
|
|
|
*/
|
|
|
|
interface SynchronizableInterface
|
|
|
|
{
|
|
|
|
/**
|
2015-08-29 08:40:10 +02:00
|
|
|
* @coroutine
|
|
|
|
*
|
2015-08-31 18:57:55 +02:00
|
|
|
* Asynchronously invokes a callback while maintaining an exclusive lock on the object.
|
2015-07-16 01:12:18 +02:00
|
|
|
*
|
2015-08-31 18:57:55 +02:00
|
|
|
* The given callback will be passed the object being synchronized on as the first argument. If the callback throws
|
|
|
|
* an exception, the lock on the object will be immediately released.
|
2015-08-31 11:19:49 +02:00
|
|
|
*
|
2015-09-03 00:23:22 +02:00
|
|
|
* @param callable<(mixed $data): mixed> $callback The synchronized callback to invoke.
|
2015-07-16 01:12:18 +02:00
|
|
|
*
|
2015-08-29 08:40:10 +02:00
|
|
|
* @return \Generator
|
|
|
|
*
|
2015-08-31 11:19:49 +02:00
|
|
|
* @resolve mixed The return value of $callback.
|
2015-07-16 01:12:18 +02:00
|
|
|
*/
|
|
|
|
public function synchronized(callable $callback);
|
|
|
|
}
|