0.0.26 • Published 8 years ago
uupaa.thread.js v0.0.26
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.
});
0.0.26
8 years ago
0.0.25
9 years ago
0.0.24
9 years ago
0.0.23
9 years ago
0.0.22
10 years ago
0.0.21
10 years ago
0.0.20
10 years ago
0.0.19
10 years ago
0.0.18
10 years ago
0.0.17
10 years ago
0.0.16
10 years ago
0.0.15
10 years ago
0.0.14
10 years ago
0.0.11
10 years ago
0.0.9
10 years ago
0.0.8
10 years ago
0.0.7
10 years ago
0.0.6
10 years ago
0.0.5
10 years ago
0.0.4
10 years ago
0.0.3
10 years ago
0.0.2
10 years ago
0.0.1
10 years ago
0.0.0
10 years ago