示例#1
0
func init() {
	go func() {
		// 等待main中的init()执行完毕
		cache.WaitInit(0)
		sdl.proxy = proxy.New()
	}()
}
示例#2
0
	// 全局代理IP
	proxy *proxy.Proxy
	// 标记是否使用代理IP
	useProxy bool
	// 全局历史记录
	history history.Historier
	// 全局读写锁
	sync.RWMutex
}

// 定义全局调度
var sdl = &scheduler{
	history: history.New(),
	status:  status.RUN,
	count:   make(chan bool, cache.Task.ThreadNum),
	proxy:   proxy.New(),
}

func Init() {
	for sdl.proxy == nil {
		runtime.Gosched()
	}
	sdl.matrices = make(map[int]*Matrix)
	sdl.count = make(chan bool, cache.Task.ThreadNum)
	if cache.Task.Mode == status.OFFLINE {
		sdl.history.ReadSuccess(cache.Task.OutType, cache.Task.SuccessInherit)
		sdl.history.ReadFailure(cache.Task.OutType, cache.Task.FailureInherit)
	}
	if cache.Task.ProxyMinute > 0 {
		if sdl.proxy.Count() > 0 {
			sdl.useProxy = true