Package Exports
- uupaa.thread.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (uupaa.thread.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Thread.js 
Thread and ThreadPool functions.
This module made of WebModule.
Documentation
Browser, NW.js and Electron
// main.html
<script src="<module-dir>/lib/WebModule.js"></script>
<script src="<module-dir>/lib/Thread.js"></script>
<script>
var thread = new WebModule.Thread("worker.js", function postMessageHandler(args) {
;
}, function(exitCode) {
switch (exitCode) {
case Thread.EXIT_OK: console.log("Closed."); break;
case Thread.EXIT_ERROR: console.log("Terminates with an error from WorkerThread. " + errorMessage); break;
case Thread.EXIT_FORCE: console.log("Forced termination by user."); break;
case Thread.EXIT_TIMEOUT: console.log("Watchdog barked.");
}
});
thread.post(["HELLO", 123], null, function postbackMessageHandler(args) {
console.log(args[0]); // "HELLO WORLD"
thread.close();
});
</script>
WebWorkers
// worker.js
importScripts("<module-dir>/lib/WebModule.js");
importScripts("<module-dir>/lib/ThreadProxy.js");
var thread = new WebModule.ThreadProxy(function postMessageHandler(args, event) {
console.log(args[0]); // "HELLO"
console.log(args[1]); // 123
event.postback(args[0] + " WORLD"); // call to postbackMessageHandler
}, function closeRequestHandler(yes, ng) {
// .... destruction process...
yes(); // -> closed as usual.
});