createInstance = function () {

        var instance = new JobClass(job.options, {});

        //We only need a subset of the methods
        instance.run = job.obj.run;
        instance.fail = job.obj.fail;
        instance.debug = job.obj.debug;
        instance.status = job.obj.status;
        instance.exit = job.obj.exit;
        instance.add = job.obj.add;

        //Called when a job wants to dynamically add input outside of job.input() using job.add()
        instance.add = function (input, dont_flatten) {
            if (!isMaster) {
                //Send the added input back to the master so that it is evenly distributed among workers
                master.send(['add', job.id, input, dont_flatten]);
            } else {
                job.master.emit('addInput', input, dont_flatten);
            }
        }

        //Handle job output and continue processing
        instance.emit = function (result) {
            worker.emit('output', result);
            instance.cancel_timeout();
            instance.isComplete = true;

            var emit = function () {
                job.instances--;

                //Reuse the instance later on
                job.instance_pool.push(instance);

                worker.emit('process');
            };

            if (job.options.wait) {
                setTimeout(emit, job.options.wait * 1000);
            } else {
                emit();
            }
        };

        //exit() is handled by the master
        if (!isMaster) {
            instance.exit = function (err) {
                master.send(['err', job.id, err]);
            };
        }

        //skip() is an alias for emitting an undefined result
        instance.skip = instance.emit;

        //If no custom fail() method is provided, fail() === skip()
        if (typeof instance.fail !== 'function') {
            instance.fail = instance.emit;
        }

        //Handle retries
        instance.retry = function () {
            instance.finish(function () {

                //Handle the case where only a certain amount of retries is permitted
                if (job.options.retries !== false) {
                    var input_hash = utils.crc32(JSON.stringify(instance.assigned_input));
                    if (typeof job.retry_hashes[input_hash] === 'undefined') {
                        job.retry_hashes[input_hash] = 1;
                    } else {
                        job.retry_hashes[input_hash]++;
                    }
                }

                if (job.options.retries !== false && job.retry_hashes[input_hash] > job.options.retries) {

                    var ret = instance.fail(instance.assigned_input, 'retry');
                    if (typeof ret !== 'undefined' && ret !== null) {
                        instance.emit(ret);
                    };

                } else {

                    job.instances--;

                    //Re-add the assigned input
                    if (instance.assigned_input instanceof Array) {
                        for (var i = 0, l = instance.assigned_input.length; i < l; i++) {
                            job.input.push(instance.assigned_input[i]);
                        }
                    } else {
                        job.input.push(instance.assigned_input);
                    }

                    //Reuse the instance later on, only if there's more retry (see bug #148)
                    job.instance_pool.push(instance);
                }

                //Continue processing
                worker.emit('process');
            });
        };

        return instance;
    }
Sets up job events to be handled by the slave or child process.

@param {Object} job
@param {Object} master (optional)
@api public