mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-06-01 03:25:00 +02:00
22 lines
402 B
PHP
22 lines
402 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Pool;
|
|
|
|
class Worker
|
|
{
|
|
|
|
public function __construct()
|
|
{
|
|
// let's say that constuctor does really expensive work...
|
|
// for example creates "thread"
|
|
}
|
|
|
|
public function run($image, array $callback)
|
|
{
|
|
// do something with $image...
|
|
// and when it's done, execute callback
|
|
call_user_func($callback, $this);
|
|
}
|
|
|
|
}
|