Skip to content

Commit 202d881

Browse files
committed
v5.5.7 fix sharedarray support
1 parent 80e9a84 commit 202d881

7 files changed

+40
-26
lines changed

build/hamsters.node.min.js

+11-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/hamsters.node.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/hamsters.web.min.js

+11-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/hamsters.web.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"author": "Austin K Smith",
44
"description": "100% Vanilla Javascript Multithreading & Parallel Execution Library",
55
"homepage": "http://www.hamsters.io/",
6-
"version": "5.5.6",
6+
"version": "5.5.7",
77
"main": "build/hamsters.node.min.js",
88
"scripts": {
99
"build": "rm -rf ./build && webpack --config ./hamsters.webpack.config.js && npm run copy-common && npm run copy-build",

src/core/pool.js

+14-8
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,22 @@ class Pool {
106106
}
107107
return new Worker(hamsterWheel);
108108
}
109-
109+
110110
/**
111-
* @function prepareMeal - Prepares a message to send to a thread and invoke execution
111+
* @function prepareMeal
112+
* @description Prepares message to send to a thread and invoke execution
112113
* @param {number} index - Index of the subarray to process
113-
* @param {number} subTaskId - ID of the subtask
114+
* @param {number} subTaskId - Subtask ID
114115
* @param {object} task - Provided library functionality options for this task
115-
* @return {object} - Prepared message to send to a thread
116+
* @returns {object} - Prepared message to send to a thread
116117
*/
117118
prepareMeal(index, subTaskId, task) {
118119
index.id = subTaskId;
119-
120+
120121
// Prepare the base hamsterFood object
121122
const hamsterFood = {
122-
array: task.input.array.length !== 0 ? this.hamsters.data.getSubArrayFromIndex(index, task) : [],
123+
array: task.input.array && task.input.array.length !== 0 ?
124+
this.hamsters.data.getSubArrayFromIndex(index, task) : [],
123125
index: index
124126
};
125127

@@ -128,9 +130,12 @@ class Pool {
128130
hamsterFood.sharedBuffer = task.scheduler.sharedBuffer;
129131
}
130132

131-
// Add other input properties, excluding 'array' and 'threads'
133+
// List of excluded keys
134+
const excludedKeys = new Set(['array', 'threads', 'sharedArray']);
135+
136+
// Iterate over task.input properties and add to hamsterFood
132137
for (const key in task.input) {
133-
if (task.input.hasOwnProperty(key) && key !== 'array' && key !== 'threads' && key !== 'sharedArray') {
138+
if (task.input.hasOwnProperty(key) && !excludedKeys.has(key)) {
134139
hamsterFood[key] = task.input[key];
135140
}
136141
}
@@ -139,6 +144,7 @@ class Pool {
139144
}
140145

141146

147+
142148
/**
143149
* @function runTask - Runs function using thread
144150
* @param {object} hamster - The thread to run the task

src/hamsters.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class hamstersjs {
2727
constructor() {
2828
'use strict';
2929

30-
this.version = '5.5.6';
30+
this.version = '5.5.7';
3131
this.run = this.hamstersRun.bind(this);
3232
this.promise = this.hamstersPromise.bind(this);
3333
this.init = this.inititializeLibrary.bind(this);

0 commit comments

Comments
 (0)