Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Welcome to our site

Take a moment to join our board

Sign in to follow this  
Spirited

Tasks in Golang

Recommended Posts

Introduction

Tasks is a library for implementing an async-await design pattern in Golang for recoverable, safe goroutine execution. Allows goroutines to be waited upon, canceled, etc. using channels and wait groups. Statuses are returned for fault tolerance checks. If the child goroutine panics, the task recovers and doesn't stop the main execution of the program.

Examples

Below is a simple example of implementing tasks for a single task and multiple tasks. More examples can be found in tasks_test.go, where 100% of the code is covered by tests.

import "spirited.io/tasks"

// This is an example of a single task
task := tasks.Start(nil, MyFunction)
task.Wait()
import (
    "spirited.io/tasks"
    "sync"
)

// This is an example of a single task
var wg sync.WaitGroup
tasks.Start(&wg, MyFirstFunction)
tasks.Start(&wg, MySecondFunction)
wg.Wait()

Link

https://gitlab.com/spirited/tasks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site, you agree to our Terms of Use.