C# Класс Gearman.Worker

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
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.

Описание методов

Worker() публичный Метод

Default constructor, initialize empty method map of strings -> delegates
public Worker ( ) : System
Результат System

Worker() публичный Метод

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 ///
Результат System

Worker() публичный Метод

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) ///
Результат System

registerFunction() публичный Метод

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) ///
Результат void

run() публичный Метод

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
Результат void

stopWorkLoop() публичный Метод

Terminate the work thread.
public stopWorkLoop ( ) : void
Результат void

workLoop() публичный Метод

Get this thing going.
public workLoop ( ) : void
Результат void