concurrent

package
v0.2.60 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: LGPL-2.1 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAsyncRetClosed = fmt.Errorf("%w: async result closed", exception.ErrCore)
)

Functions

func MakeAsyncRet

func MakeAsyncRet() chan Ret

MakeAsyncRet 创建异步调用结果

func UnsafeContext deprecated

func UnsafeContext(ctx Context) _UnsafeContext

Deprecated: UnsafeContext 访问上下文内部方法

Types

type AsyncRet

type AsyncRet <-chan Ret

AsyncRet 异步调用结果

func (AsyncRet) Wait

func (asyncRet AsyncRet) Wait(ctx context.Context) Ret

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 ConcurrentContextProvider

type ConcurrentContextProvider interface {
	// GetConcurrentContext 获取多线程安全的上下文
	GetConcurrentContext() iface.Cache
}

ConcurrentContextProvider 多线程安全的上下文提供者

type Context

type Context interface {
	context.Context

	// GetParentContext 获取父上下文
	GetParentContext() context.Context
	// GetAutoRecover panic时是否自动恢复
	GetAutoRecover() bool
	// GetReportError 在开启panic时自动恢复时,将会恢复并将错误写入此error channel
	GetReportError() chan error
	// GetWaitGroup 获取等待组
	GetWaitGroup() *sync.WaitGroup
	// GetCancelFunc 获取取消运行函数
	GetCancelFunc() context.CancelFunc
	// contains filtered or unexported methods
}

Context 上下文

type ContextBehavior

type ContextBehavior struct {
	context.Context
	// contains filtered or unexported fields
}

ContextBehavior 上下文行为

func (*ContextBehavior) GetAutoRecover

func (ctx *ContextBehavior) GetAutoRecover() bool

GetAutoRecover panic时是否自动恢复

func (*ContextBehavior) GetCancelFunc

func (ctx *ContextBehavior) GetCancelFunc() context.CancelFunc

GetCancelFunc 获取取消运行函数

func (*ContextBehavior) GetParentContext

func (ctx *ContextBehavior) GetParentContext() context.Context

GetParentContext 获取父上下文

func (*ContextBehavior) GetReportError

func (ctx *ContextBehavior) GetReportError() chan error

GetReportError 在开启panic时自动恢复时,将会恢复并将错误写入此error channel

func (*ContextBehavior) GetWaitGroup

func (ctx *ContextBehavior) GetWaitGroup() *sync.WaitGroup

GetWaitGroup 获取等待组

type CurrentContextProvider

type CurrentContextProvider interface {
	ConcurrentContextProvider
	// GetCurrentContext 获取当前上下文
	GetCurrentContext() iface.Cache
}

CurrentContextProvider 当前上下文提供者

type Ret

type Ret struct {
	Value any   // 返回值
	Error error // error
}

Ret 调用结果

func MakeRet

func MakeRet(val any, err error) Ret

MakeRet 创建调用结果

func (Ret) OK

func (ret Ret) OK() bool

OK 是否成功

func (Ret) String

func (ret Ret) String() string

String implements fmt.Stringer

Jump to

Keyboard shortcuts

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