diff options
| author | Richard Musiol <mail@richard-musiol.de> | 2018-10-11 12:46:14 +0200 |
|---|---|---|
| committer | Richard Musiol <neelance@gmail.com> | 2018-11-10 11:57:17 +0000 |
| commit | 6dd70fc5e391eb7a47be5eb6353107f38b73f161 (patch) | |
| tree | e5ba2aa9f1dcaa4ab396417129b0a04c27b8d0e9 /src/runtime/proc.go | |
| parent | e3e043bea4d7547edf004a9e202f66a4d69b5899 (diff) | |
| download | go-6dd70fc5e391eb7a47be5eb6353107f38b73f161.tar.xz | |
all: add support for synchronous callbacks to js/wasm
With this change, callbacks returned by syscall/js.NewCallback
get executed synchronously. This is necessary for the APIs of
many JavaScript libraries.
A callback triggered during a call from Go to JavaScript gets executed
on the same goroutine. A callback triggered by JavaScript's event loop
gets executed on an extra goroutine.
Fixes #26045
Fixes #27441
Change-Id: I591b9e85ab851cef0c746c18eba95fb02ea9e85b
Reviewed-on: https://go-review.googlesource.com/c/142004
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/proc.go')
| -rw-r--r-- | src/runtime/proc.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 864efcdfed..8631608c06 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -2280,10 +2280,10 @@ stop: } // wasm only: - // Check if a goroutine is waiting for a callback from the WebAssembly host. - // If yes, pause the execution until a callback was triggered. - if pauseSchedulerUntilCallback() { - // A callback was triggered and caused at least one goroutine to wake up. + // If a callback returned and no other goroutine is awake, + // then pause execution until a callback was triggered. + if beforeIdle() { + // At least one goroutine got woken. goto top } |
