Start a new OS thread.
(fn uintptr, args unsafe.Pointer, stackSize uintptr)
| 100 | |
| 101 | // Start a new OS thread. |
| 102 | func 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 |
| 125 | func taskExited(t *Task) { |
nothing calls this directly
no test coverage detected