interruptor
Version:
Run a function with the possibility to interrupt it from another thread
20 lines • 711 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.interrupt = exports.runInterruptible = void 0;
const bindings_1 = __importDefault(require("bindings"));
const native = (0, bindings_1.default)('interruptor');
function runInterruptible(fn) {
return native.runInterruptible((index) => {
return fn({ __id: index });
});
}
exports.runInterruptible = runInterruptible;
function interrupt(handle) {
native.interrupt(handle.__id);
process.memoryUsage();
}
exports.interrupt = interrupt;
//# sourceMappingURL=index.js.map