Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Thread and ThreadPool functions.

License

NotificationsYou must be signed in to change notification settings

uupaa/Thread.js

Repository files navigation

npm

Thread and ThreadPool functions.

This module made ofWebModule.

Documentation

Browser, NW.js and Electron

// main.html<scriptsrc="<module-dir>/lib/WebModule.js"></script><scriptsrc="<module-dir>/lib/Thread.js"></script><script>var thread = new WebModule.Thread("worker.js", function postMessageHandler(args){;}, function(exitCode){switch(exitCode){caseThread.EXIT_OK:console.log("Closed.");break;caseThread.EXIT_ERROR:console.log("Terminates with an error from WorkerThread. "+errorMessage);break;caseThread.EXIT_FORCE:console.log("Forced termination by user.");break;caseThread.EXIT_TIMEOUT:console.log("Watchdog barked.");}});thread.post(["HELLO",123],null,functionpostbackMessageHandler(args){console.log(args[0]);// "HELLO WORLD"thread.close();});</script>

WebWorkers

// worker.jsimportScripts("<module-dir>/lib/WebModule.js");importScripts("<module-dir>/lib/ThreadProxy.js");varthread=newWebModule.ThreadProxy(functionpostMessageHandler(args,event){console.log(args[0]);// "HELLO"console.log(args[1]);// 123event.postback(args[0]+" WORLD");// call to postbackMessageHandler},functioncloseRequestHandler(yes,ng){// .... destruction process...yes();// -> closed as usual.});

About

Thread and ThreadPool functions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp