Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@matrixai/workers

Package Overview
Dependencies
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@matrixai/workers - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

91

dist/WorkerManager.js

@@ -21,11 +21,2 @@ "use strict";

};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -41,3 +32,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

this._started = false;
this.logger = logger !== null && logger !== void 0 ? logger : new logger_1.default(this.constructor.name);
this.logger = logger ?? new logger_1.default(this.constructor.name);
}

@@ -57,38 +48,32 @@ get started() {

*/
start({ workerFactory, cores, }) {
return __awaiter(this, void 0, void 0, function* () {
try {
if (this._started) {
return;
}
this.logger.info('Starting WorkerManager');
this._started = true;
this.pool = threads_1.Pool(workerFactory, cores);
this.logger.info(`Started WorkerManager`);
}
catch (e) {
this._started = false;
throw e;
}
});
}
stop() {
return __awaiter(this, void 0, void 0, function* () {
if (!this._started) {
async start({ workerFactory, cores, }) {
try {
if (this._started) {
return;
}
this.logger.info('Stopping WorkerManager');
yield this.pool.terminate();
this.logger.info('Starting WorkerManager');
this._started = true;
this.pool = threads_1.Pool(workerFactory, cores);
this.logger.info(`Started WorkerManager`);
}
catch (e) {
this._started = false;
this.logger.info('Stopped WorkerManager');
});
throw e;
}
}
call(f) {
return __awaiter(this, void 0, void 0, function* () {
if (!this._started) {
throw new errors.ErrorWorkerManagerNotStarted();
}
return yield this.pool.queue(f);
});
async stop() {
if (!this._started) {
return;
}
this.logger.info('Stopping WorkerManager');
await this.pool.terminate();
this._started = false;
this.logger.info('Stopped WorkerManager');
}
async call(f) {
if (!this._started) {
throw new errors.ErrorWorkerManagerNotStarted();
}
return await this.pool.queue(f);
}
queue(f) {

@@ -100,17 +85,13 @@ if (!this._started) {

}
completed() {
return __awaiter(this, void 0, void 0, function* () {
if (!this._started) {
throw new errors.ErrorWorkerManagerNotStarted();
}
return yield this.pool.completed();
});
async completed() {
if (!this._started) {
throw new errors.ErrorWorkerManagerNotStarted();
}
return await this.pool.completed();
}
settled() {
return __awaiter(this, void 0, void 0, function* () {
if (!this._started) {
throw new errors.ErrorWorkerManagerNotStarted();
}
return yield this.pool.settled();
});
async settled() {
if (!this._started) {
throw new errors.ErrorWorkerManagerNotStarted();
}
return await this.pool.settled();
}

@@ -117,0 +98,0 @@ }

{
"name": "@matrixai/workers",
"version": "1.1.0",
"version": "1.1.1",
"author": "Roger Qiu",

@@ -5,0 +5,0 @@ "description": "Multithreaded Workers",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc