当前位置: 首页 > news >正文

建立网站服务器营销技巧培训ppt

建立网站服务器,营销技巧培训ppt,关于网站开发费用的入账,首码项目推广网站derfer : 延迟调用,函数结束返回时执行,多个defer按照先进后出的顺序调用 原理:底层通过链表实现,每次新增的defer调用,通过头插法插入链表;defer执行时,从链表头开始遍历,相当于实…

derfer : 延迟调用,函数结束返回时执行,多个defer按照先进后出的顺序调用

原理:底层通过链表实现,每次新增的defer调用,通过头插法插入链表;defer执行时,从链表头开始遍历,相当于实现了后加入的defer先执行,先加的defer后执行

defer结构体

type _defer struct {started boolheap    bool// openDefer indicates that this _defer is for a frame with open-coded// defers. We have only one defer record for the entire frame (which may// currently have 0, 1, or more defers active).openDefer boolsp        uintptr // sp at time of deferpc        uintptr // pc at time of deferfn        func()  // can be nil for open-coded defers_panic    *_panic // panic that is running deferlink      *_defer // next defer on G; can point to either heap or stack!// If openDefer is true, the fields below record values about the stack// frame and associated function that has the open-coded defer(s). sp// above will be the sp for the frame, and pc will be address of the// deferreturn call in the function.fd   unsafe.Pointer // funcdata for the function associated with the framevarp uintptr        // value of varp for the stack frame// framepc is the current pc associated with the stack frame. Together,// with sp above (which is the sp associated with the stack frame),// framepc/sp can be used as pc/sp pair to continue a stack trace via// gentraceback().framepc uintptr
}

defer初始化

// Create a new deferred function fn, which has no arguments and results.
// The compiler turns a defer statement into a call to this.
func deferproc(fn func()) {gp := getg()if gp.m.curg != gp {// go code on the system stack can't deferthrow("defer on system stack")}d := newdefer()if d._panic != nil {throw("deferproc: d.panic != nil after newdefer")}// 这里使用头插法 插入链表d.link = gp._defergp._defer = dd.fn = fnd.pc = getcallerpc()// We must not be preempted between calling getcallersp and// storing it to d.sp because getcallersp's result is a// uintptr stack pointer.d.sp = getcallersp()// deferproc returns 0 normally.// a deferred func that stops a panic// makes the deferproc return 1.// the code the compiler generates always// checks the return value and jumps to the// end of the function if deferproc returns != 0.return0()// No code can go here - the C return register has// been set and must not be clobbered.
}

defer执行

func deferreturn() {gp := getg()for {d := gp._deferif d == nil {return}sp := getcallersp()if d.sp != sp {return}if d.openDefer {done := runOpenDeferFrame(gp, d)if !done {throw("unfinished open-coded defers in deferreturn")}gp._defer = d.linkfreedefer(d)// If this frame uses open defers, then this// must be the only defer record for the// frame, so we can just return.return}fn := d.fnd.fn = nil// 指向下一个defer节点gp._defer = d.linkfreedefer(d)fn()}
}
http://www.ahscrl.com/news/594.html

相关文章:

  • 做网站带后台多少钱百度搜索关键词排名靠前
  • 网站正在建设中 html代码朋友圈广告投放
  • 帝国文章网站模板百度提交入口的网址
  • 怎么做图片网站微营销推广平台有哪些
  • 没网站可以做快排吗东莞网站建设推广
  • python入门教程完整版班级优化大师简介
  • wordpress高级设置网站站外优化推广方式
  • 如何建手机网站网站推广与优化平台
  • 上海宝山做网站公司排名百度关键词竞价和收费的方法
  • 高端电子商务网站建设温州网站优化推广方案
  • 哈尔滨网站建设公司哪家好自己建网站需要钱吗
  • 昆明网站建设价目表祁阳seo
  • bootstrap的网站模板学seo哪个培训好
  • 公司网站建设设计百度seo 优化
  • 温州招聘网seo黑帽有哪些技术
  • 在哪里买空间做网站优化营商环境个人心得
  • 龙江网站开发如何建网站
  • 金峰辉网站建设广东疫情最新数据
  • dw做静态网站网店如何做推广
  • 个人网站可以做音乐下载网综合型b2b电子商务平台网站
  • 关卡页面设计越秀seo搜索引擎优化
  • 天津手机版建站系统百度seo高级优化
  • 卖手表的交易平台哪个好seo关键词优化外包
  • 南京电子商务网站建设大连网站开发公司
  • 安徽中色十二冶金建设有限公司网站展示型网页设计公司
  • 广州网站优化费用新闻稿代写
  • 网站建设遇到的问题友链提交入口
  • 西樵网站设计百度搜索热词排行榜
  • 什么系统做网站最安全免费网站注册免费创建网站
  • 从0开始做网站百度推广代理查询