public function SomeUndefinedLongRunningWork($timeToWorkOnSomething, callable $onComplete = null)
    {
        if ($this->isExternal()) {
            $timeToWorkOnSomething *= 100;
            echo "Start work $timeToWorkOnSomething msec on thread: " . posix_getpid() . PHP_EOL;
            //just a simulation on different time running process
            usleep($timeToWorkOnSomething);
            //not required but return everything you like
            //lets return a message to display on parent
            echo "Completed work $timeToWorkOnSomething msec on thread: " . posix_getpid();
            return "Completed work $timeToWorkOnSomething msec on thread: " . posix_getpid();
        } else {
            return $this->asyncCallOnChild(__FUNCTION__, array($timeToWorkOnSomething), $onComplete, function (AsyncMessage $messga) {
                var_dump($messga->GetResult()->getMessage());
            });
        }
    }
public function SomeUndefinedLongRunningWork($timeToWorkOnSomething, callable $onComplete = null)
    {
        if ($this->isExternal()) {
            $timeToWorkOnSomething *= 100;
            echo "Start work $timeToWorkOnSomething msec on thread: " . posix_getpid() . PHP_EOL;
            //just a simulation on different time running process
            usleep($timeToWorkOnSomething);
            //not required but return everything you like
            //lets return a message to display on parent
            echo "Completed work $timeToWorkOnSomething msec on thread: " . posix_getpid();
            return "Completed work $timeToWorkOnSomething msec on thread: " . posix_getpid();
        } else {
            return $this->asyncCallOnChild(__FUNCTION__, array($timeToWorkOnSomething), $onComplete, function (AsyncMessage $messga) {
                var_dump($messga->GetResult()->getMessage());
            });
        }
    }
public function SomeUndefinedLongRunningWork ( $ timeToWorkOnSomething , callable $ onComplete = null ) { if ( $ this -> isExternal ( ) ) { $ timeToWorkOnSomething *= 100 ; echo "Start work $timeToWorkOnSomething msec on thread: " . posix_getpid ( ) . PHP_EOL ; //just a simulation on different time running process
 usleep ( $ timeToWorkOnSomething ) ; //not required but return everything you like
 //lets return a message to display on parent
 echo "Completed work $timeToWorkOnSomething msec on thread: " . posix_getpid ( ) ; return "Completed work $timeToWorkOnSomething msec on thread: " . posix_getpid ( ) ; } else { return $ this -> asyncCallOnChild ( __FUNCTION__ , array ( $ timeToWorkOnSomething ) , $ onComplete , function ( AsyncMessage $ messga ) { var_dump ( $ messga -> GetResult ( ) -> getMessage ( ) ) ; } ) ; } }
Function to do some async work on thread class
@param int $timeToWorkOnSomething
@param callable $onComplete
@return AsyncMessage
Function to do some async work on thread class