Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ResourceManager ¶
type ResourceManager struct {
// contains filtered or unexported fields
}
ResourceManager is a fair manager for distributing limited amount of resources to requesters.
func New ¶
func New(limit int64) *ResourceManager
New returns a new ResourceManager with `limit` number of resources.
func (*ResourceManager) Release ¶
func (m *ResourceManager) Release(n int64)
Release `n` resource to the manager.
func (*ResourceManager) Request ¶
func (m *ResourceManager) Request(key string, data interface{}, n int64, notifyC chan interface{}, cancelC chan struct{}) (acquired bool)
Request `n` resource from the manager for key `key`. Release must be called after done with the resource.
func (*ResourceManager) Stats ¶
func (m *ResourceManager) Stats() Stats
Stats returns statistics about current status.
Click to show internal directories.
Click to hide internal directories.