-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
217 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2024 The Emscripten Authors. All rights reserved. | ||
// Emscripten is available under two separate licenses, the MIT license and the | ||
// University of Illinois/NCSA Open Source License. Both these licenses can be | ||
// found in the LICENSE file. | ||
|
||
#include <emscripten.h> | ||
#include <stdio.h> | ||
|
||
int main() | ||
{ | ||
printf("Before MAIN_THREAD_EM_ASM_AWAIT\n"); | ||
int res = MAIN_THREAD_EM_ASM_AWAIT({ | ||
out('Inside MAIN_THREAD_EM_ASM_AWAIT: ' + $0 + ' ' + $1); | ||
const asyncOp = new Promise((resolve,reject) => { | ||
setTimeout(() => { | ||
out('Inside asyncOp'); | ||
resolve(2); | ||
}, 1000); | ||
}); | ||
return asyncOp; | ||
}, 42, 3.5); | ||
printf("After MAIN_THREAD_EM_ASM_AWAIT\n"); | ||
printf("result: %d\n", res); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Before MAIN_THREAD_EM_ASM_AWAIT | ||
Inside MAIN_THREAD_EM_ASM_AWAIT: 42 3.5 | ||
Inside asyncOp | ||
After MAIN_THREAD_EM_ASM_AWAIT | ||
result: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2024 The Emscripten Authors. All rights reserved. | ||
// Emscripten is available under two separate licenses, the MIT license and the | ||
// University of Illinois/NCSA Open Source License. Both these licenses can be | ||
// found in the LICENSE file. | ||
|
||
#include <emscripten.h> | ||
#include <stdio.h> | ||
#include <pthread.h> | ||
|
||
int main() | ||
{ | ||
// start new thread | ||
pthread_t thread; | ||
pthread_create(&thread, NULL, [](void*) -> void* { | ||
printf("Before MAIN_THREAD_EM_ASM_AWAIT\n"); | ||
int res = MAIN_THREAD_EM_ASM_AWAIT({ | ||
out('Inside MAIN_THREAD_EM_ASM_AWAIT: ' + $0 + ' ' + $1); | ||
const asyncOp = new Promise((resolve,reject) => { | ||
setTimeout(() => { | ||
out('Inside asyncOp'); | ||
reject(2); | ||
}, 1000); | ||
}); | ||
return asyncOp; | ||
}, 42, 3.5); | ||
printf("After MAIN_THREAD_EM_ASM_AWAIT rejected\n"); | ||
printf("result: %d\n", res); | ||
return NULL; | ||
}, NULL); | ||
|
||
// wait for thread to finish | ||
pthread_join(thread, NULL); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Before MAIN_THREAD_EM_ASM_AWAIT | ||
Inside MAIN_THREAD_EM_ASM_AWAIT: 42 3.5 | ||
Inside asyncOp | ||
After MAIN_THREAD_EM_ASM_AWAIT rejected | ||
result: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
4186 | ||
4219 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
8728 | ||
8810 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
19405 | ||
19656 |
Oops, something went wrong.