Skip to content

Commit 7c997cf

Browse files
committed
Add support for alert() call from pthread
1 parent e8b6839 commit 7c997cf

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/library_pthread.js

+2
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ var LibraryPThread = {
242242
Module['print']('Thread ' + e.data.threadId + ': ' + e.data.text);
243243
} else if (e.data.cmd === 'printErr') {
244244
Module['printErr']('Thread ' + e.data.threadId + ': ' + e.data.text);
245+
} else if (e.data.cmd == 'alert') {
246+
alert('Thread ' + e.data.threadId + ': ' + e.data.text);
245247
} else if (e.data.cmd === 'exit') {
246248
// todo
247249
} else if (e.data.cmd === 'cancelDone') {

src/pthread-main.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ function threadPrintErr() {
3131
var text = Array.prototype.slice.call(arguments).join(' ');
3232
postMessage({cmd: 'printErr', text: text, threadId: selfThreadId});
3333
}
34-
34+
function threadAlert() {
35+
var text = Array.prototype.slice.call(arguments).join(' ');
36+
postMessage({cmd: 'alert', text: text, threadId: selfThreadId});
37+
}
3538
Module['print'] = threadPrint;
3639
Module['printErr'] = threadPrintErr;
3740

@@ -41,6 +44,8 @@ console = {
4144
error: threadPrintErr
4245
};
4346

47+
this.alert = threadAlert;
48+
4449
this.onmessage = function(e) {
4550
if (e.data.cmd === 'load') { // Preload command that is called once per worker to parse and load the Emscripten code.
4651
buffer = e.data.buffer;

0 commit comments

Comments
 (0)