Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Custodian ¶
type Custodian struct {
// contains filtered or unexported fields
}
Custodian provides a timeout service for objects. The timeout is the same for all enqueued objects. Order is retained.
func New ¶
func New(timeout time.Duration, notifyCb CustodyNotify) *Custodian
New creates a new Custodian. Timeout specifies the timeout of the Custodian, notifyCb specifies the callback function that is called by the Custodian when a timeout expires.
func (*Custodian) Elements ¶
func (c *Custodian) Elements() []CustodyPair
Elements returns all objects that are currently under custody.
func (*Custodian) Register ¶
Register enqueues a new object to the custodian. The data object is referred to by id.
func (*Custodian) Remove ¶
Remove removes an object from custody. No callback will be invoked on this object anymore.
func (*Custodian) RemoveAll ¶
func (c *Custodian) RemoveAll() []CustodyPair
RemoveAll deletes all objects from custody. No callbacks will be invoked. RemoveAll returns all objects that have been under custody.
type CustodyNotify ¶
type CustodyNotify func(id string, data interface{})
CustodyNotify is the callback function type as called by the Custodian when the timeout expires
type CustodyPair ¶
type CustodyPair struct { ID string Data interface{} }
CustodyPair is a tuple of enqueued id and data object