public function process_work($blocking = true, $bucket = self::DEFAULT_BUCKET, $process_all_buckets = false)
	{
		$this->housekeeping_check();

		// process work on all buckets if desired
		if ($process_all_buckets === true)
		{
			foreach ($this->buckets as $bucket_slot)
			{
				$this->process_work($blocking, $bucket_slot, false);
			}
			return true;
		}

		// if room fork children
		if ($blocking === true)
		{
			// process work until completed
			while ($this->work_sets_count($bucket) > 0)
			{
				// check to make sure we have not hit or exceded the max children (globally or within the bucket)
				while ( $this->children_running($bucket) >= $this->max_children[$bucket] )
				{
					$this->housekeeping_check();
					$this->signal_handler_sigchild(SIGCHLD);
					sleep(1);
				}

				$this->process_work_unit($bucket);
			}

			// wait until work finishes
			while ($this->children_running($bucket) > 0)
			{
				sleep(1);
				$this->housekeeping_check();
				$this->signal_handler_sigchild(SIGCHLD);
			}

			// make call back to parent exit function if it exists
			$this->invoke_callback($this->parent_function_exit, array(self::$parent_pid), true);
		}
		else
		{
			// fork children until max
			while ( $this->children_running($bucket) < $this->max_children[$bucket] )
			{
				if (!$this->child_persistent_mode[$bucket] && $this->work_sets_count($bucket) == 0)
				{
					return true;
				}

				$this->process_work_unit($bucket);
			}
		}

		return true;
	}
public function process_work($blocking = true, $bucket = self::DEFAULT_BUCKET, $process_all_buckets = false)
	{
		$this->housekeeping_check();

		// process work on all buckets if desired
		if ($process_all_buckets === true)
		{
			foreach ($this->buckets as $bucket_slot)
			{
				$this->process_work($blocking, $bucket_slot, false);
			}
			return true;
		}

		// if room fork children
		if ($blocking === true)
		{
			// process work until completed
			while ($this->work_sets_count($bucket) > 0)
			{
				// check to make sure we have not hit or exceded the max children (globally or within the bucket)
				while ( $this->children_running($bucket) >= $this->max_children[$bucket] )
				{
					$this->housekeeping_check();
					$this->signal_handler_sigchild(SIGCHLD);
					sleep(1);
				}

				$this->process_work_unit($bucket);
			}

			// wait until work finishes
			while ($this->children_running($bucket) > 0)
			{
				sleep(1);
				$this->housekeeping_check();
				$this->signal_handler_sigchild(SIGCHLD);
			}

			// make call back to parent exit function if it exists
			$this->invoke_callback($this->parent_function_exit, array(self::$parent_pid), true);
		}
		else
		{
			// fork children until max
			while ( $this->children_running($bucket) < $this->max_children[$bucket] )
			{
				if (!$this->child_persistent_mode[$bucket] && $this->work_sets_count($bucket) == 0)
				{
					return true;
				}

				$this->process_work_unit($bucket);
			}
		}

		return true;
	}
public function process_work ( $ blocking = true , $ bucket = self :: DEFAULT_BUCKET , $ process_all_buckets = false ) { $ this -> housekeeping_check ( ) ; // process work on all buckets if desired if ( $ process_all_buckets === true ) { foreach ( $ this -> buckets as $ bucket_slot ) { $ this -> process_work ( $ blocking , $ bucket_slot , false ) ; } return true ; } // if room fork children if ( $ blocking === true ) { // process work until completed while ( $ this -> work_sets_count ( $ bucket ) > 0 ) { // check to make sure we have not hit or exceded the max children (globally or within the bucket) while ( $ this -> children_running ( $ bucket ) >= $ this -> max_children [ $ bucket ] ) { $ this -> housekeeping_check ( ) ; $ this -> signal_handler_sigchild ( SIGCHLD ) ; sleep ( 1 ) ; } $ this -> process_work_unit ( $ bucket ) ; } // wait until work finishes while ( $ this -> children_running ( $ bucket ) > 0 ) { sleep ( 1 ) ; $ this -> housekeeping_check ( ) ; $ this -> signal_handler_sigchild ( SIGCHLD ) ; } // make call back to parent exit function if it exists $ this -> invoke_callback ( $ this -> parent_function_exit , array ( self :: $ parent_pid ) , true ) ; } else { // fork children until max while ( $ this -> children_running ( $ bucket ) < $ this -> max_children [ $ bucket ] ) { if ( ! $ this -> child_persistent_mode [ $ bucket ] && $ this -> work_sets_count ( $ bucket ) == 0 ) { return true ; } $ this -> process_work_unit ( $ bucket ) ; } } return true ; }
Process work on the work queue

This function will take work sets and hand them off to children.
Part of the process is calling invoking fork_work_unit to fork
off the child. If $blocking is set to true, this function will
process all work units and wait until the children are done until
returning.  If $blocking is set to false, this function will
start as many work units as max_children allows and then return.

Note, if $blocking is turned off, the caller has to handle when
the children are done with their current load.

@param bool $blocking            True for blocking mode, false for immediate return.
@param int  $bucket              The bucket to use.
@param bool $process_all_buckets If we should process all the buckets.
@return bool
Process work on the work queue