class PlatformAbstractJob implements PlatformJob, Externalizable {
    /** Marker object denoting the job execution result is stored in native platform. */
    static final Object LOC_JOB_RES = new Object();

    /** Ignite instance. */
    @IgniteInstanceResource
    protected transient Ignite ignite;

    /** Parent task; present only on local job instance. */
    protected transient PlatformAbstractTask task;

    /** Pointer to job in the native platform. */
    protected transient long ptr;

    /** Job. */
    protected Object job;

    /** Job name. */
    protected String jobName;

    /**
     * {@link java.io.Externalizable} support.
     */
    protected PlatformAbstractJob() {
        // No-op.
    }

    /**
     * Constructor.
     *
     * @param task Parent task.
     * @param ptr Pointer.
     * @param job Job.
     * @param jobName Job name.
     */
    protected PlatformAbstractJob(PlatformAbstractTask task, long ptr, Object job, String jobName) {
        this.task = task;
        this.ptr = ptr;
        this.job = job;
        this.jobName = jobName;
    }

    /** {@inheritDoc} */
    @Nullable @Override public Object execute() {
        try {
            PlatformProcessor interopProc = PlatformUtils.platformProcessor(ignite);

            interopProc.awaitStart();

            return execute0(interopProc.context());
        }
        catch (IgniteCheckedException e) {
            throw U.convertException(e);
        }
    }

    /**
     * Internal job execution routine.
     *
     * @param ctx Interop processor.
     * @return Result.
     * @throws org.apache.ignite.IgniteCheckedException If failed.
     */
    protected abstract Object execute0(PlatformContext ctx) throws IgniteCheckedException;

    /**
     * Create job in native platform if needed.
     *
     * @param ctx Context.
     * @return {@code True} if job was created, {@code false} if this is local job and creation is not necessary.
     * @throws org.apache.ignite.IgniteCheckedException If failed.
     */
    protected boolean createJob(PlatformContext ctx) throws IgniteCheckedException {
        if (ptr == 0) {
            try (PlatformMemory mem = ctx.memory().allocate()) {
                PlatformOutputStream out = mem.output();

                BinaryRawWriterEx writer = ctx.writer(out);

                writer.writeObject(job);

                out.synchronize();

                ptr = ctx.gateway().computeJobCreate(mem.pointer());
            }

            return true;
        }
        else
            return false;
    }

    /**
     * Run local job.
     *
     * @param ctx Context.
     * @param cancel Cancel flag.
     * @return Result.
     */
    protected Object runLocal(PlatformContext ctx, boolean cancel) {<FILL_FUNCTION_BODY>}

    /** {@inheritDoc} */
    @Override public long pointer() {
        return ptr;
    }

    /** {@inheritDoc} */
    @Override public Object job() {
        return job;
    }

    /** {@inheritDoc} */
    @Override public String name() {
        return jobName;
    }
}

        // Local job, must execute it with respect to possible concurrent task completion.
        if (task.onJobLock()) {
            try {
                ctx.gateway().computeJobExecuteLocal(ptr, cancel ? 1 : 0);

                return LOC_JOB_RES;
            }
            finally {
                task.onJobUnlock();
            }
        }
        else
            // Task has completed concurrently, no need to run the job.
            return null;
    
<no_super_class>