task_none.mx raw

   1  //go:build scheduler.none
   2  
   3  package task
   4  
   5  import "unsafe"
   6  
   7  // state is a no-op placeholder. With scheduler.none there is no
   8  // stack switching, so the state struct is empty.
   9  type state struct{}
  10  
  11  // currentTask is the single running task.
  12  var currentTask Task
  13  
  14  // Current returns the (only) active task.
  15  func Current() *Task {
  16  	return &currentTask
  17  }
  18  
  19  // Pause panics — with no scheduler there is nothing to resume us.
  20  func Pause() {
  21  	// Debug: trap to get a stack trace.
  22  	runtimePanic("deadlock: Pause called with no scheduler")
  23  }
  24  
  25  // Resume is unreachable with scheduler.none.
  26  func (t *Task) Resume() {
  27  	runtimePanic("deadlock: Resume called with no scheduler")
  28  }
  29  
  30  // OnSystemStack returns true — with no scheduler, we're always on
  31  // the system stack.
  32  func OnSystemStack() bool {
  33  	return true
  34  }
  35  
  36  // SystemStack returns 0. Never called when OnSystemStack() is true.
  37  func SystemStack() uintptr {
  38  	return 0
  39  }
  40  
  41  // start is a no-op under scheduler.none — there are no goroutines to start.
  42  func start(fn uintptr, args unsafe.Pointer, stackSize uintptr) {
  43  	runtimePanic("cannot start goroutine with no scheduler")
  44  }
  45  
  46  //go:linkname runtimePanic runtime.runtimePanic
  47  func runtimePanic(str string)
  48