MCPcopy
hub / github.com/tinygo-org/tinygo / start

Function start

src/internal/task/task_threads.go:102–122  ·  view source on GitHub ↗

Start a new OS thread.

(fn uintptr, args unsafe.Pointer, stackSize uintptr)

Source from the content-addressed store, hash-verified

100
101// Start a new OS thread.
102func start(fn uintptr, args unsafe.Pointer, stackSize uintptr) {
103 t := &Task{}
104 t.state.id = atomic.AddUintptr(&goroutineID, 1)
105 if verbose {
106 println("*** start: ", t.state.id, "from", Current().state.id)
107 }
108
109 // Start the new thread, and add it to the list of threads.
110 // Do this with a lock so that only started threads are part of the queue
111 // and the stop-the-world GC won't see threads that haven't started yet or
112 // are not fully started yet.
113 activeTaskLock.Lock()
114 errCode := tinygo_task_start(fn, args, t, &t.state.thread, &t.state.stackTop, stackSize)
115 if errCode != 0 {
116 runtimePanic("could not start thread")
117 }
118 t.state.QueueNext = activeTasks
119 activeTasks = t
120 otherGoroutines++
121 activeTaskLock.Unlock()
122}
123
124//export tinygo_task_exited
125func taskExited(t *Task) {

Callers

nothing calls this directly

Calls 5

tinygo_task_startFunction · 0.85
CurrentFunction · 0.70
runtimePanicFunction · 0.70
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected