Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CancellableLifetime ¶
type CancellableLifetime struct {
// contains filtered or unexported fields
}
CancellableLifetime describes a lifetime for a resource that allows checking out the resource and returning it and once cancelled will not allow any further checkouts.
func NewCancellableLifetime ¶
func NewCancellableLifetime() *CancellableLifetime
NewCancellableLifetime returns a new cancellable resource lifetime.
func (*CancellableLifetime) Cancel ¶
func (l *CancellableLifetime) Cancel()
Cancel will wait for all current checkouts to be returned and then will cancel the lifetime so that it cannot be checked out any longer.
func (*CancellableLifetime) ReleaseCheckout ¶
func (l *CancellableLifetime) ReleaseCheckout()
ReleaseCheckout will decrement the number of current checkouts, it MUST only be called after a call to TryCheckout and must not be called more than once per call to TryCheckout or else it will panic as it will try to unlock an unlocked resource.
func (*CancellableLifetime) TryCheckout ¶
func (l *CancellableLifetime) TryCheckout() bool
TryCheckout will try to checkout the resource, if the lifetime is already cancelled this will return false, otherwise it will return true and guarantee the lifetime is not cancelled until the checkout is returned. If this returns true you MUST call ReleaseCheckout later, otherwise the lifetime will never close and any caller calling Cancel will be blocked indefinitely.