"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.forkChildProcess = exports.ChildProcessWorker = void 0;
const child_process_1 = require("child_process");
const _base_1 = require("./_base");
class ChildProcessWorker extends _base_1.WorkerPlatformBase {
    constructor(path) {
        super();
        this.worker = (0, child_process_1.fork)(path);
        this.worker.on('message', (m) => this.emit('message', m));
        this.worker.on('close', () => this.emit('close'));
        this.worker.on('error', (e) => this.emit('error', e));
    }
    kill() {
        this.worker.kill();
    }
    send(m) {
        this.worker.send(m);
    }
}
exports.ChildProcessWorker = ChildProcessWorker;
function forkChildProcess(pathToWorker) {
    return new ChildProcessWorker(pathToWorker);
}
exports.forkChildProcess = forkChildProcess;
//# sourceMappingURL=childProcess.js.map