looptask

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallTask

type CallTask struct {
	ID        int64
	Function  otto.Value
	Args      []interface{}
	Value     chan otto.Value
	Error     chan error
	SoftError bool
}

CallTask schedules an otto.Value (which should be a function) to be called with a specific set of arguments. It has two channels for communicating the result of the call.

func NewCallTask

func NewCallTask(fn otto.Value, args ...interface{}) *CallTask

NewCallTask creates a new CallTask object for a given otto.Value (which should be a function) and set of arguments, creating two buffered channels for the response.

func (CallTask) Cancel

func (c CallTask) Cancel()

Cancel does nothing for a CallTask, as there's nothing to clean up.

func (CallTask) Execute

func (c CallTask) Execute(vm *otto.Otto, l *loop.Loop) error

Execute calls the associated function (not necessarily in the given vm), pushing the resultant return value and error (or nil) into the associated channels. If the call results in an error, it will return that error.

func (CallTask) GetID

func (c CallTask) GetID() int64

GetID gets the ID of a CallTask.

func (*CallTask) SetID

func (c *CallTask) SetID(ID int64)

SetID sets the ID of a CallTask.

type EvalTask

type EvalTask struct {
	ID        int64
	Script    interface{}
	Value     chan otto.Value
	Error     chan error
	SoftError bool
}

EvalTask schedules running an otto.Script. It has two channels for communicating the result of the execution.

func NewEvalTask

func NewEvalTask(s interface{}) *EvalTask

NewEvalTask creates a new EvalTask for a given otto.Script, creating two buffered channels for the response.

func (EvalTask) Cancel

func (e EvalTask) Cancel()

Cancel does nothing for an EvalTask, as there's nothing to clean up.

func (EvalTask) Execute

func (e EvalTask) Execute(vm *otto.Otto, l *loop.Loop) error

Execute runs the EvalTask's otto.Script in the vm provided, pushing the resultant return value and error (or nil) into the associated channels. If the execution results in an error, it will return that error.

func (EvalTask) GetID

func (e EvalTask) GetID() int64

GetID gets the ID of an EvalTask.

func (*EvalTask) SetID

func (e *EvalTask) SetID(ID int64)

SetID sets the ID of an EvalTask.

type IdleTask

type IdleTask struct {
	ID int64
}

IdleTask is designed to sit in a loop and keep it active, without doing any work.

func NewIdleTask

func NewIdleTask() *IdleTask

NewIdleTask creates a new IdleTask object.

func (IdleTask) Cancel

func (i IdleTask) Cancel()

Cancel does nothing on an IdleTask, as there's nothing to clean up.

func (IdleTask) Execute

func (i IdleTask) Execute(vm *otto.Otto, l *loop.Loop) error

Execute always returns an error for an IdleTask, as it should never actually be run.

func (IdleTask) GetID

func (i IdleTask) GetID() int64

GetID gets the ID of an IdleTask.

func (*IdleTask) SetID

func (i *IdleTask) SetID(ID int64)

SetID sets the ID of an IdleTask.

Jump to

Keyboard shortcuts

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