1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-04 02:27:55 +01:00
parallel/lib/Sync/Synchronizable.php

26 lines
808 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.
*/
2016-01-23 07:00:56 +01:00
public function synchronized(callable $callback): \Generator;
}