Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wire

Wire

Wire is a little experiment allowing inline workers using Blobs to simulate the thread experience.

Examples

  // Start a new thread
  new Wire(function() {
    while(true) {
      // Complex operation
    }
  });


  // Comunicate
  var thread = new Wire(function() {
    onmessage = function(message) {
      postMessage("You said: " + message.data);
    };
  });

  thread.onmessage(function(message) {
    console.log("thread said: " + message.data);
  });

  // Name a thread
  var thread = new Wire("my_thread", function() {
    while(true) {
      // Complex operation
    }
  });

  thread.onmessage(function(message) {
    console.log(this.name + " said: " + message.data);
  });

  // Access all the created threads
  for(var i = 0; i < 50; i++) {
    new Wire(function() {
      while(true) {
        // Complex operation
      }
    });
  };

  Wire.threads.length
  // 50

About

HTML5 workers without a separate file

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages