From 347132825e0772af348656b4e8f0ea2d8c30baec Mon Sep 17 00:00:00 2001 From: Stephen Coakley Date: Fri, 11 Dec 2015 23:28:44 -0600 Subject: [PATCH] Gut lame factories --- CHANGELOG.md | 3 --- src/Worker/WorkerForkFactory.php | 16 ---------------- src/Worker/WorkerProcessFactory.php | 16 ---------------- src/Worker/WorkerThreadFactory.php | 16 ---------------- tests/Worker/ForkPoolTest.php | 10 ++++++++-- tests/Worker/ThreadPoolTest.php | 10 ++++++++-- 6 files changed, 16 insertions(+), 55 deletions(-) delete mode 100644 src/Worker/WorkerForkFactory.php delete mode 100644 src/Worker/WorkerProcessFactory.php delete mode 100644 src/Worker/WorkerThreadFactory.php diff --git a/CHANGELOG.md b/CHANGELOG.md index f707b52..5e74167 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,6 @@ All notable changes to this project will be documented in this file. This projec ## Unreleased -### Added -- You can now easily create worker pools that use a fixed worker type with new dedicated worker factories: `Worker\WorkerThreadFactory`, `Worker\WorkerForkFactory`, and `Worker\WorkerProcessFactory`. - ### Changed - Updated to Icicle `0.9.x` packages. diff --git a/src/Worker/WorkerForkFactory.php b/src/Worker/WorkerForkFactory.php deleted file mode 100644 index 80219da..0000000 --- a/src/Worker/WorkerForkFactory.php +++ /dev/null @@ -1,16 +0,0 @@ -getMock(WorkerFactory::class); + $factory->method('create')->will($this->returnCallback(function () { + return new WorkerFork(); + })); + + return new DefaultPool($min, $max, $factory); } } diff --git a/tests/Worker/ThreadPoolTest.php b/tests/Worker/ThreadPoolTest.php index 92c8cc5..c9bd1ae 100644 --- a/tests/Worker/ThreadPoolTest.php +++ b/tests/Worker/ThreadPoolTest.php @@ -2,7 +2,8 @@ namespace Icicle\Tests\Concurrent\Worker; use Icicle\Concurrent\Worker\DefaultPool; -use Icicle\Concurrent\Worker\WorkerThreadFactory; +use Icicle\Concurrent\Worker\WorkerFactory; +use Icicle\Concurrent\Worker\WorkerThread; /** * @group threading @@ -12,6 +13,11 @@ class ThreadPoolTest extends AbstractPoolTest { protected function createPool($min = null, $max = null) { - return new DefaultPool($min, $max, new WorkerThreadFactory()); + $factory = $this->getMock(WorkerFactory::class); + $factory->method('create')->will($this->returnCallback(function () { + return new WorkerThread(); + })); + + return new DefaultPool($min, $max, $factory); } }