== GLOBAL == Both the client and the worker have access to the following functions: initialize($mode, $server_config): void - Initializes TamerLib in the given mode, if no server_config is provided then Tamer will initialize it's own server and use its own configuration. When initializing as a worker, the $server_config is ignored as the configuration is provided by the parent process. shutdown(): void - Shuts down the TamerLib by resetting the global variables and releasing any resources it may have allocated. == CLIENT == The client is the master process of TamerLib that is used to push tasks to the worker processes, optionally a client may also be responsible for supervising workers and or managing its own server process. createWorker($count, $path): void - Creates workers and starts them, the count parameter specifies how many workers to create and the path parameter being optional, if provided, specifies the path to the worker executable. If the path parameter is not provided, TamerLib will use it's own subprocess to create the workers which can only handle closures do($callable, $channel=0): string - Pushes a task to the worker pool and returns the job id, this adds the job to its own watchlist so that it can be monitored by Tamer. call($function, $args, $channel=0): string - Pushes a function call to the worker pool and returns the job id, this adds the job to its own watchlist so that it can be monitored by Tamer. dof($callable, $channel=0): void - Pushes a task to the worker pool and forgets about it, this does not add the job to the watchlist callf($function, $args, $channel=0): void - Pushes a function call to the worker pool and forgets about it, this does not add the job to the watchlist wait($callback($job_id, $return)): void - Waits for all jobs dispatched with do() to complete, the callback is called for each job that completes with the job id and the return value of the job. If one or more jobs fail, the function will throw an replicated exception. waitFor($job_id): mixed - Waits for a specific job to complete and returns the return value of the job, if the job fails, the function will throw an replicated exception. clear(): void - Clears the watchlist of all jobs. NOTE: wait & waitFor will execute supervisory tasks while waiting for jobs to complete if the client is configured to supervise workers. == WORKER == The worker is the slave process of TamerLib that is used to execute tasks pushed to it by the client process. setFunction($function, $callable): void - Sets the function that will be called when the worker receives a task with the given function name. removeFunction($function): void - Removes the function that will be called when the worker receives a task with the given function name. getFunctions(): array - Returns an array of all the functions that the worker has registered. run($channels, $timeout=0): void - Runs the worker process, this function will block until the worker is shutdown or until the timeout is reached. If the timeout is reached, the worker will shutdown. The channels parameter is an int or an array of ints that specifies which channels the worker will listen on. If the channels parameter is 0 then the worker will listen only on channel 0. return($job_id, $return): void - Returns the return value of the job to the client process, this function is called automatically when the worker completes a job. throw($job_id, $exception): void - Throws an exception to the client process, this function is called automatically when the worker completes a job and the job throws an exception. reject($job_id, $exception): void - Rejects a job, this silently rejects the job and pushes it back onto the queue for another worker to pick up.