future

package
v0.0.0-...-cfb4354 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2020 License: Zlib Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FutureTag tagFuture

FutureTag is the Tag for Future objects. Activate activates the future's result if it is available and returns self if it is not. CloneValue returns a new Future with no coroutine.

Functions

func New

func New(vm *iolang.VM, target *iolang.Object, msg *iolang.Message) *iolang.Object

New creates a new Future object with its own coroutine and runs it.

Types

type Future

type Future struct {
	// M is an atomic flag for whether the value has been computed.
	M uintptr
	// Value is the computed result, or nil while waiting for it.
	Value *iolang.Object
	// Coro is the coroutine which will fill in the value.
	Coro *iolang.VM
}

A Future is a placeholder object that will be filled in by a dedicated coroutine.

func (*Future) Wait

func (f *Future) Wait(vm *iolang.VM) (*iolang.Object, iolang.Stop)

Wait spins until the value is ready. While spinning, the future monitors the coroutine's remote control flow channel. The value is returned if it is ready, otherwise the Stop that ceased monitoring. Panics if the coroutine hasn't started yet.

NOTE: If Wait returns a Stop, then that Stop was sent to the waiting coroutine, not the Future's.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL