add object pool pattern

This commit is contained in:
Jan Brecka
2014-03-24 16:51:49 +01:00
parent b0b0d4a1a4
commit d779b1e86a
7 changed files with 166 additions and 0 deletions

22
Pool/Worker.php Normal file
View File

@@ -0,0 +1,22 @@
<?php
namespace DesignPatterns\Pool;
class Worker
{
public function __construct()
{
// let 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);
}
}