cgo

package
v0.10.3-0...-bec5499 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConsumed = errors.New("future is already consumed")

Functions

func ConsumeCStatusIntoError

func ConsumeCStatusIntoError(status *C.CStatus) error

Types

type CFuturePtr

type CFuturePtr unsafe.Pointer

type CGOAsyncFunction

type CGOAsyncFunction = func() CFuturePtr

type Future

type Future interface {

	// BlockAndLeakyGet block until the future is ready or canceled, and return the leaky result.
	//   Caller should only call once for BlockAndLeakyGet, otherwise the ErrConsumed will returned.
	//   Caller will get the merr.ErrSegcoreCancel or merr.ErrSegcoreTimeout respectively if the future is canceled or timeout.
	//   Caller will get other error if the underlying cgo function throws, otherwise caller will get result.
	//   Caller should free the result after used (defined by caller), otherwise the memory of result is leaked.
	BlockAndLeakyGet() (unsafe.Pointer, error)

	// Release the resource of the future.
	// !!! Release is not concurrent safe with other methods.
	// It should be called only once after all method of future is returned.
	Release()
	// contains filtered or unexported methods
}

func Async

func Async(ctx context.Context, f CGOAsyncFunction, opts ...Opt) Future

Async is a helper function to call a C async function that returns a future.

type Opt

type Opt func(*options)

Opt is the option type for future.

func WithName

func WithName(name string) Opt

WithName sets the name of the future. Only used for metrics.

Jump to

Keyboard shortcuts

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