Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Any ¶ added in v1.0.2
type Any = interface{}
Any is an alias for interface{} and is equivalent to interface{} in all ways.
type Callable ¶ added in v1.0.7
type Callable func() Any
Callable provides a function that returns a value of type Any.
type Cloneable ¶ added in v1.0.3
type Cloneable interface {
// Clone create and returns a copy of this object.
Clone() Any
}
Cloneable interface to support copy itself.
type Feature ¶ added in v1.0.2
type Feature interface {
// Complete notifies the parent coroutine that the task has completed and returns the execution result.
// This method is called by the child coroutine.
Complete(result Any)
// CompleteError notifies the parent coroutine that the task is terminated due to panic and returns stack information.
// This method is called by the child coroutine.
CompleteError(error Any)
// Get the execution result of the sub-coroutine, if there is no result, return nil.
// If panic is raised during the execution of the sub-coroutine, it will be raised again at this time.
// this method is called by the parent coroutine.
Get() Any
}
Feature provide a way to wait for the sub-coroutine to finish executing, get the return value of the sub-coroutine, and catch the sub-coroutine panic.
func GoWait ¶ added in v1.0.2
GoWait starts a new goroutine, and copy inheritableThreadLocals from current goroutine. This function return a Feature pointer, so we can wait by Feature.Get method. If panic occur in goroutine, The panic will be trigger again when calling Feature.Get method.
func GoWaitResult ¶ added in v1.0.2
GoWaitResult starts a new goroutine, and copy inheritableThreadLocals from current goroutine. This function return a Feature pointer, so we can wait and get result by Feature.Get method. If panic occur in goroutine, The panic will be trigger again when calling Feature.Get method.
type Runnable ¶ added in v1.0.7
type Runnable func()
Runnable provides a function without return values.
type RuntimeError ¶ added in v1.0.8
type RuntimeError interface {
// Goid returns the goid of the coroutine that created the current error.
Goid() int64
// Gopc returns the pc of go statement that created the current error coroutine.
Gopc() uintptr
// Message returns the detail message string of this error.
Message() string
// StackTrace returns an array of stack trace elements, each representing one stack frame.
StackTrace() []uintptr
// Cause returns the cause of this error or nil if the cause is nonexistent or unknown.
Cause() RuntimeError
// Error returns a short description of this error.
Error() string
}
RuntimeError runtime error with stack info.
func NewRuntimeError ¶ added in v1.0.8
func NewRuntimeError(cause Any) RuntimeError
NewRuntimeError create a new RuntimeError instance.
func NewRuntimeErrorWithMessage ¶ added in v1.0.8
func NewRuntimeErrorWithMessage(message string) RuntimeError
NewRuntimeErrorWithMessage create a new RuntimeError instance.
func NewRuntimeErrorWithMessageCause ¶ added in v1.0.8
func NewRuntimeErrorWithMessageCause(message string, cause Any) RuntimeError
NewRuntimeErrorWithMessageCause create a new RuntimeError instance.
type Supplier ¶ added in v1.0.2
type Supplier func() Any
Supplier provides a function that returns a value of type Any.
type ThreadLocal ¶ added in v1.0.2
type ThreadLocal interface {
// Get returns the value in the current goroutine's local threadLocals or inheritableThreadLocals, if it was set before.
Get() Any
// Set copy the value into the current goroutine's local threadLocals or inheritableThreadLocals.
Set(value Any)
// Remove delete the value from the current goroutine's local threadLocals or inheritableThreadLocals.
Remove()
}
ThreadLocal provides goroutine-local variables.
func NewInheritableThreadLocal ¶ added in v1.0.2
func NewInheritableThreadLocal() ThreadLocal
NewInheritableThreadLocal create and return a new ThreadLocal instance. The initial value is nil. The value can be inherited to sub goroutines witch started by Go, GoWait, GoWaitResult methods.
func NewInheritableThreadLocalWithInitial ¶ added in v1.0.2
func NewInheritableThreadLocalWithInitial(supplier Supplier) ThreadLocal
NewInheritableThreadLocalWithInitial create and return a new ThreadLocal instance. The initial value is determined by invoking the supplier method. The value can be inherited to sub goroutines witch started by Go, GoWait, GoWaitResult methods.
func NewThreadLocal ¶ added in v1.0.2
func NewThreadLocal() ThreadLocal
NewThreadLocal create and return a new ThreadLocal instance. The initial value is nil.
func NewThreadLocalWithInitial ¶ added in v1.0.2
func NewThreadLocalWithInitial(supplier Supplier) ThreadLocal
NewThreadLocalWithInitial create and return a new ThreadLocal instance. The initial value is determined by invoking the supplier method.