mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 19:17:47 +00:00
compiler: support returning values from async functions
This is implemented as follows:
* The parent coroutine allocates space for the return value in its
frame and stores a pointer to this frame in the parent coroutine
handle.
* The child coroutine obtains the alloca from its parent using the
parent coroutine handle. It then stores the result value there.
* The parent value reads the data from the alloca on resumption.
This commit is contained in:
committed by
Ron Evans
parent
fb952a722a
commit
46d5ea8cf6
@@ -107,6 +107,14 @@ func activateTask(task *coroutine) {
|
||||
runqueuePushBack(task)
|
||||
}
|
||||
|
||||
func setTaskData(task *coroutine, value unsafe.Pointer) {
|
||||
task.promise().data = uint(uintptr(value))
|
||||
}
|
||||
|
||||
func getTaskData(task *coroutine) unsafe.Pointer {
|
||||
return unsafe.Pointer(uintptr(task.promise().data))
|
||||
}
|
||||
|
||||
// Add this task to the end of the run queue. May also destroy the task if it's
|
||||
// done.
|
||||
func runqueuePushBack(t *coroutine) {
|
||||
|
||||
Reference in New Issue
Block a user