casync

package module
v0.0.0-...-37588d7 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Async

type Async struct {
	TasksChannel chan *Task // tasks to execute
	Concurrency  int        // how many go routines should be active.

	Tasks []*Task        // list of tasks for this async struct
	Sigs  chan os.Signal // catch unix sigs to graceful shutdown
	// contains filtered or unexported fields
}

func NewAsync

func NewAsync(sizeofCurrencency int, ts []*Task) *Async

build up the async process

func (*Async) ExecuteTasks

func (a *Async) ExecuteTasks()

now add the tasks to the TasksChannel

func (*Async) IsDone

func (a *Async) IsDone() bool

helper to see if the jobs are done

func (*Async) WatchTasks

func (a *Async) WatchTasks()

catch a signal and drain the tasks

type Task

type Task struct {
	Execute func() // what to execute
	// contains filtered or unexported fields
}

*

A task executes
We need to tell tasks if there is an error shutdown and don't execute
We need to interrupt a task which is running if a signal tells us to or the Tasks is executing to long
We need to control the number of executing tasks
We want to enter a task for executing when the task is ready to execute
We need to know when all tasks have completed.

Task to execute, each task has a timeout in seconds

func NewTask

func NewTask(id int, exec func()) *Task

Build the Task

func (*Task) SetTimeout

func (t *Task) SetTimeout(s int)

set a timeout

Jump to

Keyboard shortcuts

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