lang

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(obj interface{}) error

Close closes the obj if it is a Closable.

xray:api:beta

func Interrupt

func Interrupt(obj interface{}) error

Interrupt calls Interrupt() if object implements Interruptible interface, or Close() if the object implements Closable interface.

xray:api:beta

Types

type ChainedClosable

type ChainedClosable []Closable

ChainedClosable is a Closable that consists of multiple Closable objects.

func (ChainedClosable) Close

func (cc ChainedClosable) Close() error

Close implements Closable.

type Closable

type Closable interface {
	// Close release all resources used by this object, including goroutines.
	Close() error
}

Closable is the interface for objects that can release its resources.

xray:api:beta

type HasType

type HasType interface {
	// Type returns the type of the object.
	// Usually it returns (*Type)(nil) of the object.
	Type() interface{}
}

HasType is the interface for objects that knows its type.

type Interruptible

type Interruptible interface {
	Interrupt()
}

Interruptible is an interface for objects that can be stopped before its completion.

xray:api:beta

type Runnable

type Runnable interface {
	// Start starts the runnable object. Upon the method returning nil, the object begins to function properly.
	Start() error

	Closable
}

Runnable is the interface for objects that can start to work and stop on demand.

Jump to

Keyboard shortcuts

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