1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-11 16:49:51 +01:00
parallel/src/SynchronizableInterface.php

25 lines
738 B
PHP
Raw Normal View History

<?php
namespace Icicle\Concurrent;
/**
* An object that can be synchronized for exclusive access across contexts.
*/
interface SynchronizableInterface
{
/**
* @coroutine
*
2015-08-31 18:57:55 +02:00
* Asynchronously invokes a callback while maintaining an exclusive lock on the object.
*
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-09-03 00:23:22 +02:00
* @param callable<(mixed $data): mixed> $callback The synchronized callback to invoke.
*
* @return \Generator
*
* @resolve mixed The return value of $callback.
*/
public function synchronized(callable $callback);
}