Show / Hide Table of Contents

# Class ComputeJobAdapter<T>

Convenience adapter for IComputeJob<TRes> implementations. It provides the following functionality:

- Default implementation of Cancel() method and ability to check whether cancellation occurred with IsCancelled() method.
- Ability to set and get job arguments via SetArguments(Object[]) and GetArgument<TArg>(Int32) methods.

##### Inheritance

System.Object
ComputeJobAdapter<T>

##### Implements

IComputeJob<T>

##### Inherited Members

System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()

###### Namespace: Apache.Ignite.Core.Compute

###### Assembly: Apache.Ignite.Core.dll

##### Syntax

    [Serializable]
    public abstract class ComputeJobAdapter<T> : IComputeJob<T>

##### Type Parameters

Name | Description
--- | ---
T |

### Constructors

#### ComputeJobAdapter()

No-arg constructor.

##### Declaration

    protected ComputeJobAdapter()

#### ComputeJobAdapter(Object[])

Creates job with specified arguments.

##### Declaration

    protected ComputeJobAdapter(params object[] args)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Object[] | args | Optional job arguments.

### Methods

#### Cancel()

This method is called when system detects that completion of this job can no longer alter the overall outcome (for example, when parent task has already reduced the results).

Note that job cancellation is only a hint, and it is really up to the actual job instance to gracefully finish execution and exit.

##### Declaration

    public void Cancel()

#### Execute()

Executes this job.

##### Declaration

    public abstract T Execute()

##### Returns

Type | Description
--- | ---
T | Job execution result (possibly `null`). This result will be returned in IComputeJobResult<TRes> object passed into OnResult(IComputeJobResult<TJobRes>, IList<IComputeJobResult<TJobRes>>) on caller node.

#### GetArgument<TArg>(Int32)

Sets given arguments.

##### Declaration

    public TArg GetArgument<TArg>(int idx)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | idx | Index of the argument.

##### Returns

Type | Description
--- | ---
TArg |

##### Type Parameters

Name | Description
--- | ---
TArg |

#### IsCancelled()

This method tests whether or not this job was cancelled. This method is thread-safe and can be called without extra synchronization.

This method can be periodically called in Execute() method implementation to check whether or not this job cancelled. Note that system calls Cancel() method only as a hint and this is a responsibility of the implementation of the job to properly cancel its execution.

##### Declaration

    protected bool IsCancelled()

##### Returns

Type | Description
--- | ---
System.Boolean | `True` if this job was cancelled, `false` otherwise.

#### SetArguments(Object[])

Sets given arguments.

##### Declaration

    public void SetArguments(params object[] args)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Object[] | args | Optional job arguments to set.

### Implements

IComputeJob<TRes>