2015-08-14 19:25:07 +02:00
|
|
|
<?php
|
|
|
|
namespace Icicle\Concurrent\Worker;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A runnable unit of execution.
|
|
|
|
*/
|
2015-12-05 06:50:32 +01:00
|
|
|
interface Task
|
2015-08-14 19:25:07 +02:00
|
|
|
{
|
|
|
|
/**
|
2015-08-27 16:10:08 +02:00
|
|
|
* @coroutine
|
|
|
|
*
|
2015-08-14 19:25:07 +02:00
|
|
|
* Runs the task inside the caller's context.
|
|
|
|
*
|
2015-09-01 23:20:57 +02:00
|
|
|
* Does not have to be a coroutine, can also be a regular function returning a value.
|
2015-08-27 16:10:08 +02:00
|
|
|
*
|
2015-09-10 06:29:41 +02:00
|
|
|
* @param \Icicle\Concurrent\Worker\Environment
|
|
|
|
*
|
2015-08-27 16:10:08 +02:00
|
|
|
* @return \Generator
|
|
|
|
*
|
|
|
|
* @resolve mixed
|
2015-08-14 19:25:07 +02:00
|
|
|
*/
|
2016-01-23 07:00:56 +01:00
|
|
|
public function run(Environment $environment): \Generator;
|
2015-08-14 19:25:07 +02:00
|
|
|
}
|