github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/runtime/runtime_wasm_js_scheduler.go (about)

     1  //go:build wasm && !wasi && !scheduler.none && !wasip1 && !wasm_unknown
     2  
     3  package runtime
     4  
     5  //export resume
     6  func resume() {
     7  	go func() {
     8  		handleEvent()
     9  	}()
    10  
    11  	if wasmNested {
    12  		minSched()
    13  		return
    14  	}
    15  
    16  	wasmNested = true
    17  	scheduler()
    18  	wasmNested = false
    19  }
    20  
    21  //export go_scheduler
    22  func go_scheduler() {
    23  	if wasmNested {
    24  		minSched()
    25  		return
    26  	}
    27  
    28  	wasmNested = true
    29  	scheduler()
    30  	wasmNested = false
    31  }