github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/internal/task/task_none.go (about)

     1  //go:build scheduler.none
     2  
     3  package task
     4  
     5  import "unsafe"
     6  
     7  // There is only one goroutine so the task struct can be a global.
     8  var mainTask Task
     9  
    10  //go:linkname runtimePanic runtime.runtimePanic
    11  func runtimePanic(str string)
    12  
    13  func Pause() {
    14  	runtimePanic("scheduler is disabled")
    15  }
    16  
    17  func Current() *Task {
    18  	// Return a task struct, which is used for the recover builtin for example.
    19  	return &mainTask
    20  }
    21  
    22  //go:noinline
    23  func start(fn uintptr, args unsafe.Pointer, stackSize uintptr) {
    24  	// The compiler will error if this is reachable.
    25  	runtimePanic("scheduler is disabled")
    26  }
    27  
    28  type state struct{}
    29  
    30  func (t *Task) Resume() {
    31  	runtimePanic("scheduler is disabled")
    32  }
    33  
    34  // OnSystemStack returns whether the caller is running on the system stack.
    35  func OnSystemStack() bool {
    36  	// This scheduler does not do any stack switching.
    37  	return true
    38  }