keithwhor / multithread.js Goto Github PK
View Code? Open in Web Editor NEWIn-browser multithreading made easy
License: MIT License
In-browser multithreading made easy
License: MIT License
It would be great if this library could support transferable objects for high performance cases where it would be bad to serialize a huge typed array as JSON for example.
A few questions about the library if you don't mind:
transfer-by-ownership
?Hi, first off Ima newbie in this topic of multithreading with javascript.
Problem:
I need evaluate coords from array, so when I'm doing it the thread only takes first value of each array and dunno why.
There is a way to evaluate each value from each array?
Am I doing wrong something?
Hope help me, many thanks.
(Sorry for my english)
Code:
$.each(json, MT.process(
function (i, row) {
// Coordenadas X
var xcoor = row.xcoor;
if (xcoor.indexOf('=') !== -1)
xcoor = xcoor.split("=")[1];
xcoor = xcoor.replace("{", "").replace("}", "");
var xcoor_array = xcoor.split(',');
// Coordenadas Y
var ycoor = row.ycoor;
if (ycoor.indexOf('=') !== -1)
ycoor = ycoor.split("=")[1];
ycoor = ycoor.replace("{", "").replace("}", "");
var ycoor_array = ycoor.split(',');
// Coordenadas Z
var zcoor = row.zcoor;
if (zcoor.indexOf('=') !== -1)
zcoor = zcoor.split("=")[1];
zcoor = zcoor.replace("{", "").replace("}", "");
var zcoor_array = zcoor.split(',');
// LANTA - A
console.log('Length:', xcoor_array.length, 'Array X:', xcoor_array);
for (var i = 0; i < xcoor_array.length; i++) {
if (xcoor_array[i] != "NULL" || xcoor_array[i] != 0) {
if (ycoor_array[i] != "NULL" || ycoor_array[i] != 0) {
error = 0;
ispolygon = true;
point = {
x: parseFloat(xcoor_array[i] / 100),
y: parseFloat(ycoor_array[i] / 100),
z: parseFloat(zcoor_array[i] / 100),
equipo: row.equipo
};
return point;
}
}
}
},
function (r) {
console.log("x: ", r.x, "y: ", r.y, "inside: ", isPointInPolygon(polygon, point = {x: r.x, y: r.y}));
}
)
);
Is it possible to add JQuery to synchronous threads? It would be useful to be able to access methods like
I found this version of JQuery without DOM functions intended for web workers. Unfortunately it doesn't have the .attr() method but it does have
I don't know how to modify multithread.js to add a reference to this library and I haven't tried using Web Workers before but if it would be possible to create a fork that includes JQuery it would make multithread.js easier to use.
it broken at a error message:Uncaught SyntaxError: Unexpected identifier
I am willing to offer long term and active support for this project if that is fine with you.
I'm considering:
Hi, how does this library compare to https://github.com/calvinmetcalf/catiline ?
An interesting library. Have you found a way for a thread to wait for a message while in the middle of a function? Rather than returning from it and waiting for onmessage to be called?
Without that, it seems like the operations that currently must be asynchronous, such as AJAX calls, pretty much still must be, which eliminates a lot of the benefit.
Of course even if it were available we'd still be doing a lot of inefficient JSON-ification just to escape that...
Is there a way to pass a variable by reference allowing multiple threads to asynchronously modify a variable during runtime?
@keithwhor Never seen this kind of syntax before:
https://github.com/keithwhor/multithread.js/blob/master/multithread.js#L26
What does the /**/
mean in an variable declaration?
I want to terminate the worker if the the worker is not needed any more
var script = this._worker[type]
.toString()
.replace(/^.*?[\n\r]+/gi, '')
.replace(/\}[\s]*$/, '')
.replace(/\/\*\*\/name\/\*\*\//gi, name)
.replace(/\/\*\*\/func\/\*\*\//gi, fnStr);
Can not replace the name and fnStr ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.