PoolFactory.php 1001 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * @author Jenner <hypxm@qq.com>
  4. * @blog http://www.huyanping.cn
  5. * @license https://opensource.org/licenses/MIT MIT
  6. * @datetime: 2015/11/19 21:14
  7. */
  8. namespace Jenner\SimpleFork;
  9. class PoolFactory
  10. {
  11. /**
  12. * create a pool instance
  13. *
  14. * @return Pool
  15. */
  16. public static function newPool()
  17. {
  18. return new Pool();
  19. }
  20. /**
  21. * create a fixed pool instance
  22. *
  23. * @param int $max
  24. * @return FixedPool
  25. */
  26. public static function newFixedPool($max = 4)
  27. {
  28. return new FixedPool($max);
  29. }
  30. /**
  31. * create a parallel pool instance
  32. *
  33. * @param $callback
  34. * @param int $max
  35. * @return ParallelPool
  36. */
  37. public static function newParallelPool($callback, $max = 4)
  38. {
  39. return new ParallelPool($callback, $max);
  40. }
  41. /**
  42. * create a single pool
  43. *
  44. * @return SinglePool
  45. */
  46. public static function newSinglePool()
  47. {
  48. return new SinglePool();
  49. }
  50. }