1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-12 09:09:35 +01:00
parallel/src/Sync/Synchronizable.php

26 lines
796 B
PHP
Raw Normal View History

<?php
namespace Icicle\Concurrent\Sync;
/**
* An object that can be synchronized for exclusive access across contexts.
*/
2015-12-05 06:50:32 +01:00
interface Synchronizable
{
/**
* @coroutine
*
2015-08-31 18:57:55 +02:00
* Asynchronously invokes a callback while maintaining an exclusive lock on the object.
*
* The arguments passed to the callback depend on the implementing object. If the callback throws an exception,
* the lock on the object will be immediately released.
*
* @param callable<(mixed ...$args): \Generator|mixed> $callback The synchronized callback to invoke.
* The callback may be a regular function or a coroutine.
*
* @return \Generator
*
* @resolve mixed The return value of $callback.
*/
public function synchronized(callable $callback);
}