Skip to content

classes_tasks_taskpool.class

Daniel Spors edited this page Dec 19, 2023 · 2 revisions

Classes in file tasks/taskpool.class.php

class TaskPool

Collect large number of same tasks into a pool and let it manage the processing without overloading the system. To add Tasks to a pool simply Depend them on it:

$pool = TaskPool::Async()->SetArg('processors',10);	
for($i=0; $i<10000; $i++)	
MyTask::Async()->SetArg('tasknum',$i)->DependsOn($pool);	
$pool->Go();	

Note that 'processors' must be a numeric value between 1 and 100, default is 5.

Extends: Task

Async

INTERNAL Overwrites parent to fix 'run' method set up things.

AsyncOnce

INTERNAL Overwrites parent to fix 'run' method set up things.

Reusable

Creates a reusable TaskPool. Will check the wdf_tasks table to see if there's already a Taskpool with the same name. If so it will be used, else a new one will be created.

Definition: public static function Reusable($name)

Returns: WdfTaskModel The new or loaded TaskPool

Parameters:

  • mixed $name TaskPool name

Run

INTERNAL TaskPool loop

Clone this wiki locally