From 01e69dc0de8729888ff8662f8ed4287151f382c2 Mon Sep 17 00:00:00 2001 From: Kris Wallsmith Date: Mon, 18 May 2015 12:15:58 -0700 Subject: [PATCH] added factory --- src/Spork/Factory.php | 59 ++++++++++++++++++++++++++++++++++++ src/Spork/ProcessManager.php | 13 ++++---- 2 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 src/Spork/Factory.php diff --git a/src/Spork/Factory.php b/src/Spork/Factory.php new file mode 100644 index 0000000..f951022 --- /dev/null +++ b/src/Spork/Factory.php @@ -0,0 +1,59 @@ +dispatcher = $dispatcher ?: new EventDispatcher(); + $this->factory = $factory ?: new Factory(); $this->debug = $debug; $this->zombieOkay = false; $this->forks = array(); @@ -72,7 +73,7 @@ public function zombieOkay($zombieOkay = true) public function createBatchJob($data = null, StrategyInterface $strategy = null) { - return new BatchJob($this, $data, $strategy); + return $this->factory->createBatchJob($this, $data, $strategy); } public function process($data, $callable, StrategyInterface $strategy = null) @@ -101,7 +102,7 @@ public function fork($callable) $this->forks = array(); // setup the shared memory - $shm = new SharedMemory(null, $this->signal); + $shm = $this->factory->createSharedMemory(null, $this->signal); $message = new ExitMessage(); // phone home on shutdown @@ -146,9 +147,9 @@ public function fork($callable) } // connect to shared memory - $shm = new SharedMemory($pid); + $shm = $this->factory->createSharedMemory($pid); - return $this->forks[$pid] = new Fork($pid, $shm, $this->debug); + return $this->forks[$pid] = $this->factory->createFork($pid, $shm, $this->debug); } public function monitor($signal = SIGUSR1)