Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccessRefCount ¶
AccessRefCount adds a reference to the RefCount while the fn executes.
func WaitRefCount ¶
func WaitRefCount[T comparable]( ctx context.Context, target *ccontainer.CContainer[T], targetErr *ccontainer.CContainer[*error], ) (T, error)
WaitRefCount waits for a RefCount container handling errors. targetErr can be nil
Types ¶
type Ref ¶
type Ref[T comparable] struct { // contains filtered or unexported fields }
Ref is a reference to a RefCount.
type RefCount ¶
type RefCount[T comparable] struct { // contains filtered or unexported fields }
RefCount is a refcount driven object container. Wraps a ccontainer with a ref count mechanism. When there are no references, the container contents are released.
func NewRefCount ¶
func NewRefCount[T comparable]( ctx context.Context, target *ccontainer.CContainer[T], targetErr *ccontainer.CContainer[*error], resolver func(ctx context.Context) (T, func(), error), ) *RefCount[T]
NewRefCount builds a new RefCount. ctx, target and targetErr can be empty
func (*RefCount[T]) AddRef ¶
AddRef adds a reference to the RefCount container. cb is an optional callback to call when the value changes.
func (*RefCount[T]) SetContext ¶ added in v0.18.1
SetContext updates the context to use for the RefCount container resolution. If ctx=nil the RefCount will wait until ctx != nil to start. This also restarts resolution, if there are any refs.