Documentation
¶
Overview ¶
Package resource_manage implements a resource management.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ResourceManage ¶
ResourceManage is an interface that who want implement an management object can realize these functions.
type ResourceManageChan ¶
type ResourceManageChan struct {
// contains filtered or unexported fields
}
ResourceManageChan inherits the ResourceManage interface. In spider, ResourceManageChan manage resource of Coroutine to crawl page.
func NewResourceManageChan ¶
func NewResourceManageChan(num uint) *ResourceManageChan
NewResourceManageChan returns initialized ResourceManageChan object which contains a resource pool. The num is the resource limit.
func (*ResourceManageChan) FreeOne ¶
func (this *ResourceManageChan) FreeOne()
The FreeOne free resource and return it to resource pool.
func (*ResourceManageChan) GetOne ¶
func (this *ResourceManageChan) GetOne()
The GetOne apply for one resource. If resource pool is empty, current coroutine will be blocked.
func (*ResourceManageChan) Has ¶
func (this *ResourceManageChan) Has() uint
The Has query for how many resource has been used.
func (*ResourceManageChan) Left ¶
func (this *ResourceManageChan) Left() uint
The Left query for how many resource left in the pool.