保护调用用户函数
(callback func())
| 60 | |
| 61 | // 保护调用用户函数 |
| 62 | func (self *eventQueue) protectedCall(callback func()) { |
| 63 | |
| 64 | if self.capturePanic { |
| 65 | defer func() { |
| 66 | |
| 67 | if err := recover(); err != nil { |
| 68 | self.onPanic(err, self) |
| 69 | } |
| 70 | |
| 71 | }() |
| 72 | } |
| 73 | |
| 74 | callback() |
| 75 | } |
| 76 | |
| 77 | // 开启事件循环 |
| 78 | func (self *eventQueue) StartLoop() EventQueue { |