Coder Social home page Coder Social logo

multithread.js's People

Contributors

keithwhor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

multithread.js's Issues

Data transfer by ownership, progress messages, premature cancel

A few questions about the library if you don't mind:

  • how is the data transferred to the threads: is it copied or transferred by transfer-by-ownership?
  • any way to easily include external functions, external libraries, global constants to each thread?
  • any way to terminate threads prematurely (allowing user to cancel pending computation)?
  • any way to get progress messages from the threads (so progress bars and other UI indicators can be shown)?
  • any chance to control the threads in sync using promises. That is,
    • provide an array of, say, 30 objects that each contain the necessary data for each thread to do its calculation
    • start the maximum number of threads the client can handle (for instance start 8 threads and form a queue for 22)
    • when all threads complete, resolve a promise or reject it depending on possible raised exceptions during computation.
    • allow the before-mentioned features to be used in this synchronized batch job.

Help processing data

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.

Click here to view the image

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 use JQuery in threads?

Is it possible to add JQuery to synchronous threads? It would be useful to be able to access methods like $.post() or $.get() and $(data).attr();

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 $.post() and $.get(). https://github.com/kpozin/jquery-nodom

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.

Is this project still alive?

I am willing to offer long term and active support for this project if that is fine with you.

I'm considering:

  • Refactoring
  • Offering test coverage
  • Providing support for modern node versions
  • Improving performance

Waiting for a message in a thread

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...

var /**/name /**/ = /**/func /**/;

	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 ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.