本文整理汇总了Golang中context.Context.BaiduAds方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.BaiduAds方法的具体用法?Golang Context.BaiduAds怎么用?Golang Context.BaiduAds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类context.Context
的用法示例。
在下文中一共展示了Context.BaiduAds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Run
func (this *ReqQiushiModule) Run(inner_data *context.Context, bschan *chan bool) {
defer func() {
if len(inner_data.BaiduAds) == 0 {
*bschan <- false
} else {
*bschan <- true
}
utils.DebugLog.Write("reqqiushi set chan")
}()
var req_flag [int(MaxAdType)]bool
var req_chan [int(MaxAdType)](chan bool)
var ret_ads [int(MaxAdType)][]context.AdInfo
for i := 0; i < int(MaxAdType); i++ {
req_flag[i] = false
}
switch inner_data.Req.AdSlot.AdSlotType {
case context.AdSlotType_BANNER:
req_chan[int(Banner)] = make(chan bool)
go this.request(inner_data, Banner, &ret_ads[int(Banner)], &req_chan[int(Banner)])
req_flag[int(Banner)] = true
case context.AdSlotType_INITIALIZATION:
// req_chan[int(Initlization)] = make(chan bool)
// go this.request(inner_data, Initlization, &ret_ads[int(Initlization)], &req_chan[int(Initlization)])
// req_flag[int(Initlization)] = true
req_chan[int(Insert)] = make(chan bool)
go this.request(inner_data, Insert, &ret_ads[int(Insert)], &req_chan[Insert])
req_flag[int(Insert)] = true
case context.AdSlotType_INSERT:
req_chan[int(Insert)] = make(chan bool)
go this.request(inner_data, Insert, &ret_ads[int(Insert)], &req_chan[Insert])
req_flag[int(Insert)] = true
}
for i := 0; i < int(MaxAdType); i++ {
if req_flag[i] == true {
select {
case <-req_chan[i]:
// close(this.req_chan[i])
// 填入队列
utils.DebugLog.Write("get ret_ads . adtype[%d] ads_ret[%d]", i, len(ret_ads[i]))
for j := 0; j < len(ret_ads[i]); j++ {
inner_data.BaiduAds = append(inner_data.BaiduAds, ret_ads[i][j])
}
case <-time.After(time.Millisecond * time.Duration(this.timeout)):
utils.WarningLog.Write("req qiushi reqtype[%d] timeout", i)
}
}
}
return
}