Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frat goroutineやtinygo機能の検証 #30

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions _examples/not_support/goroutine_test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
r:
tinygo build -target ./target.json -o main.wasm main.go
cp main.wasm /home/usuyuki/.cache/mahiwa/user.wasm
wasm2wat /home/usuyuki/.cache/mahiwa/user.wasm -o /home/usuyuki/.cache/mahiwa/user.wat
(cd /home/usuyuki/.cache/mahiwa && xxd -i user.wasm > user.h)
cp /home/usuyuki/.cache/mahiwa/user.h /home/usuyuki/mahiwa_space/mahiwa-backend/src/wasm/user.h

7 changes: 7 additions & 0 deletions _examples/not_support/goroutine_test/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module github.com/project-mahiwa/mahiwa-frontend-go/_examples/not_support/goroutine_test

go 1.21.3

require github.com/project-mahiwa/mahiwa-frontend-go v0.0.0-00010101000000-000000000000

replace github.com/project-mahiwa/mahiwa-frontend-go => ../../../../mahiwa-frontend-go
22 changes: 22 additions & 0 deletions _examples/not_support/goroutine_test/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"github.com/project-mahiwa/mahiwa-frontend-go/arduino"
"github.com/project-mahiwa/mahiwa-frontend-go/serial"
)

// goroutineをしたとき、wasmでどう表現されているのかを見る。
func main() {
serial.Println("main routine")
go func() {
serial.Println("goroutine")
}()
arduino.Delay(1000) // mainルーチンをgoroutineより先に終了させないためのdelay
// 普通のgoでは
// main routine
// goroutine
// の順で表示されるが、mahiwaで動かすと
// main routine
// Error: [trap] stack overflow ()
// となり、実行不可
}
Binary file added _examples/not_support/goroutine_test/main.wasm
Binary file not shown.
Loading