Pool.php 627 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jenner
  5. * Date: 2015/8/12
  6. * Time: 17:54
  7. */
  8. namespace Jenner\SimpleFork;
  9. /**
  10. * pool
  11. *
  12. * @package Jenner\SimpleFork
  13. */
  14. class Pool extends AbstractPool
  15. {
  16. /**
  17. * add a process
  18. *
  19. * @param Process $process
  20. * @param null|string $name process name
  21. * @return int
  22. */
  23. public function execute(Process $process, $name = null)
  24. {
  25. if (!is_null($name)) {
  26. $process->name($name);
  27. }
  28. if (!$process->isStarted()) {
  29. $process->start();
  30. }
  31. return array_push($this->processes, $process);
  32. }
  33. }