resource_manage

package
v0.0.0-...-85ede20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2015 License: MPL-2.0 Imports: 0 Imported by: 3

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

type ResourceManage interface {
	GetOne()
	FreeOne()
	Has() uint
	Left() uint
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL