kphp icon indicating copy to clipboard operation
kphp copied to clipboard

how to parallel code execution with job workers? (CLI)

Open giosh04 opened this issue 3 years ago • 0 comments

In Swoole PHP I can run something like

<?php

function test(){
  while(true){
    sleep(3);
    echo "3\n";
  }
  return null;
}

function test2(){
  while(true){
    sleep(1);
    echo "1\n";
  }
  return null;
}

Co\run(function (){

  go(function () {
    test();
  });

  go(function () {
    test2();
  });

});


 ?>

Result will be 1 1 1 3 1 1 1 3 3 3

How to run in parallel mode 2 while(true) functions with job workers in CLI MODE? Could you please provide simplest example of parallelism with out http?

giosh04 avatar Mar 29 '22 12:03 giosh04