C# Class Gearman.Worker

Afficher le fichier Open project: johnewart/gearman.net Class Usage Examples

Méthodes publiques

Méthode Description
Worker ( ) : System

Default constructor, initialize empty method map of strings -> delegates

Worker ( string host ) : System

Constructor requiring only the host name; the default port of 4730 is used

Worker ( string host, int port ) : System

Constructor requiring both the host and the port number to connect to

registerFunction ( string taskname, taskdelegate function ) : void

Add a task <--> delegate mapping to this worker. A task name is a short string that the worker registers with the manager, for example "reverse". The delegate is a callback that the worker calls when it receives a packet of work to do that has a task name matching the registered name.

run ( ) : void

Obligatory run method for the Thread. Runs indefinitely, checking for a job every 2 seconds TODO: make this time adjustable if needed

stopWorkLoop ( ) : void

Terminate the work thread.

workLoop ( ) : void

Get this thing going.

Private Methods

Méthode Description
checkForJob ( ) : void

Checks with the manager for a new job to work on. The manager has a record of all the tasks that the worker is capable of working on, so most of the real work here is done by the manager to find something for the worker to work on. If something is assigned, load the data, execute the callback and then return the data to the manager so that the worker can move on to something else.

Method Details

Worker() public méthode

Default constructor, initialize empty method map of strings -> delegates
public Worker ( ) : System
Résultat System

Worker() public méthode

Constructor requiring only the host name; the default port of 4730 is used
public Worker ( string host ) : System
host string /// A representing the host to connect to ///
Résultat System

Worker() public méthode

Constructor requiring both the host and the port number to connect to
public Worker ( string host, int port ) : System
host string /// A representing the host to connect to ///
port int /// A port to connect to (if other than the default of 4730) ///
Résultat System

registerFunction() public méthode

Add a task <--> delegate mapping to this worker. A task name is a short string that the worker registers with the manager, for example "reverse". The delegate is a callback that the worker calls when it receives a packet of work to do that has a task name matching the registered name.
public registerFunction ( string taskname, taskdelegate function ) : void
taskname string /// A that is the 'name' of the task being registered with the server ///
function taskdelegate /// A that is the actual callback function /// (must match the specification) ///
Résultat void

run() public méthode

Obligatory run method for the Thread. Runs indefinitely, checking for a job every 2 seconds TODO: make this time adjustable if needed
public run ( ) : void
Résultat void

stopWorkLoop() public méthode

Terminate the work thread.
public stopWorkLoop ( ) : void
Résultat void

workLoop() public méthode

Get this thing going.
public workLoop ( ) : void
Résultat void