mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-09-26 06:19:20 +02:00
add object pool pattern
This commit is contained in:
22
Pool/Worker.php
Normal file
22
Pool/Worker.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user