go-co: github.com/magicdawn/go-co Index | Files | Directories

package co

import "github.com/magicdawn/go-co"

Package co : async/await for glolang


Package Files

co.go task.go vars.go

func Await Uses

func Await(t *Task) (interface{}, error)

Await : await a Task & return it's result

e.g res := co.Await(Task)

type Task Uses

type Task struct {
    // communicate via Channel
    Channel chan interface{}

    // store the result of the Task
    Result interface{}

    // store error
    Error error

func Async Uses

func Async(fn func() interface{}) *Task

Async : create a new *Task execute fn , save the result, send to channel

e.g co.Async(func() interface{}{

return val
// val will be Task's Result


func (*Task) Continue Uses

func (t *Task) Continue(fn func(*Task) interface{}) *Task



Package co imports 1 packages (graph) and is imported by 1 packages. Updated 2020-05-28. Refresh now. Tools for package owners.