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

26 lines
822 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.
*
* @param callable<(self $synchronized): \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);
}