async

package
v0.3.18 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: LGPL-2.1 Imports: 5 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MakeRet = MakeRetT[any]
	VoidRet = MakeRet(nil, nil)
)
View Source
var (
	ErrAsyncRetClosed = fmt.Errorf("%w: async result closed", exception.ErrCore)
)
View Source
var (
	MakeAsyncRet = MakeAsyncRetT[any]
)

Functions

func MakeAsyncRetT

func MakeAsyncRetT[T any]() chan RetT[T]

MakeAsyncRetT 创建异步调用结果

Types

type AsyncRet

type AsyncRet = AsyncRetT[any]

type AsyncRetT

type AsyncRetT[T any] <-chan RetT[T]

AsyncRetT 异步调用结果

func (AsyncRetT[T]) Wait

func (asyncRet AsyncRetT[T]) Wait(ctx context.Context) RetT[T]

Wait 等待异步调用结果

type Callee

type Callee interface {
	// PushCall 将调用函数压入接受者的任务处理流水线,返回AsyncRet。
	PushCall(fun generic.FuncVar0[any, Ret], va ...any) AsyncRet
	// PushCallDelegate 将调用委托压入接受者的任务处理流水线,返回AsyncRet。
	PushCallDelegate(fun generic.DelegateFuncVar0[any, Ret], va ...any) AsyncRet
	// PushCallVoid 将调用函数压入接受者的任务处理流水线,返回AsyncRet。
	PushCallVoid(fun generic.ActionVar0[any], va ...any) AsyncRet
	// PushCallVoidDelegate 将调用委托压入接受者的任务处理流水线,返回AsyncRet。
	PushCallVoidDelegate(fun generic.DelegateActionVar0[any], va ...any) AsyncRet
}

Callee 异步调用接受者

type Caller

type Caller interface {
	// Call 异步调用函数,有返回值。不会阻塞当前线程,会返回AsyncRet。
	//
	//	注意:
	//	- 代码片段中的线程安全问题,如临界区访问、线程死锁等。
	//  - 调用过程中的panic信息,均会转换为error返回。
	Call(fun generic.FuncVar0[any, Ret], va ...any) AsyncRet

	// CallDelegate 异步调用委托,有返回值。不会阻塞当前线程,会返回AsyncRet。
	//
	//	注意:
	//	- 代码片段中的线程安全问题,如临界区访问、线程死锁等。
	//  - 调用过程中的panic信息,均会转换为error返回。
	CallDelegate(fun generic.DelegateFuncVar0[any, Ret], va ...any) AsyncRet

	// CallVoid 异步调用函数,无返回值。在运行时中。不会阻塞当前线程,会返回AsyncRet。
	//
	//	注意:
	//	- 代码片段中的线程安全问题,如临界区访问、线程死锁等。
	//  - 调用过程中的panic信息,均会转换为error返回。
	CallVoid(fun generic.ActionVar0[any], va ...any) AsyncRet

	// CallVoidDelegate 异步调用委托,无返回值。在运行时中。不会阻塞当前线程,会返回AsyncRet。
	//
	//	注意:
	//	- 代码片段中的线程安全问题,如临界区访问、线程死锁等。
	//  - 调用过程中的panic信息,均会转换为error返回。
	CallVoidDelegate(fun generic.DelegateActionVar0[any], va ...any) AsyncRet
}

Caller 异步调用发起者

type Ret

type Ret = RetT[any]

type RetT

type RetT[T any] struct {
	Value T     // 返回值
	Error error // error
}

RetT 调用结果

func AsRetT

func AsRetT[T any](ret Ret) (RetT[T], bool)

AsRetT 转换

func CastRetT

func CastRetT[T any](ret Ret) RetT[T]

CastRetT 转换

func MakeRetT

func MakeRetT[T any](val T, err error) RetT[T]

MakeRetT 创建调用结果

func (RetT[T]) OK

func (ret RetT[T]) OK() bool

OK 是否成功

func (RetT[T]) String

func (ret RetT[T]) String() string

String implements fmt.Stringer

Jump to

Keyboard shortcuts

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