Git Product home page Git Product logo

vkthread's Introduction

vkThread

is a javascript plugin, which allows you to execute any function of a your code in a thread.

The only folder you need to have on you server is vkthread. The rest stuff are examples, demo, etc.

Standalone function: simply pass it as an argument to the vkthread(), and get the result in a callback function. You don't need to create a separate file for each thread, like you normally do with a regular worker.

Object's method: vkthread accepts context as an optional parameter and executes function in its context. Simply pass the object as a context, that's it.

Function with dependencies: vkthread accepts a list of filenames as an optional argument and imports these files in the thread before the function is calling

Here is a basic example:

function sum(num1, num2) {
    return num1 + num2;
}

in main page you execute it this way:

var foo = sum(2,3);

console.log(foo);

now, let's open a new thread and execute function sum() in this thread.

vkthread.exec( sum,  //function to execute in a thread
          [2,3],  //arguments for the function
          function(data){ //collback function to process result
              var foo = data;
              console.log(foo);
          });

See live examples at http://eslinstructor.net/vkthread

vkThread is built on HTML5 "Worker" technology. It also incorporates JSONfn code to implement the key tasks. In spite of technical complexity, plugin is super compact. Development version (plain text with comments) is less than 2k. I don't care to minify it.

vkthread's People

Contributors

vkiryukhin avatar

Watchers

 avatar  avatar

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.