(wait *sync.WaitGroup)
| 154 | } |
| 155 | |
| 156 | func (this *module) Run(wait *sync.WaitGroup) { |
| 157 | runtime.LockOSThread() |
| 158 | defer this.recover(wait) |
| 159 | wait.Add(1) |
| 160 | defer wait.Done() |
| 161 | this.begin_time = time.Now().UnixNano() / 1e9 |
| 162 | timer_manager := this.timer_manager |
| 163 | var ( |
| 164 | event_msg EventMsg = nil |
| 165 | close_flag bool = false |
| 166 | ev_queue = this.ev_queue |
| 167 | event_chan = ev_queue.SemaChan() |
| 168 | timer_tick = time.NewTimer(time.Duration(MODULE_TIMER_INTERVAL) * time.Millisecond) |
| 169 | tick_c = timer_tick.C |
| 170 | nextWake = 0 |
| 171 | event_list = this.event_list |
| 172 | ) |
| 173 | |
| 174 | for { |
| 175 | for { |
| 176 | if this.event_index >= this.event_count { |
| 177 | this.event_count = ev_queue.Get(event_list, uint32(MODULE_EVENT_LENGTH)) |
| 178 | this.event_index = 0 |
| 179 | } |
| 180 | for this.event_index < this.event_count { |
| 181 | event_msg = event_list[this.event_index].(EventMsg) |
| 182 | event_list[this.event_index] = nil |
| 183 | this.event_index++ |
| 184 | this.handle_event(event_msg) |
| 185 | this.op_count++ |
| 186 | } |
| 187 | nextWake = timer_manager.Execute(100) |
| 188 | if this.event_count <= 0 && nextWake > 0 { |
| 189 | break |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | if ev_queue.WaitNotify() == false { |
| 194 | continue |
| 195 | } |
| 196 | |
| 197 | timer_tick.Reset(time.Duration(nextWake) * time.Millisecond) |
| 198 | select { |
| 199 | case close_flag = <-this.close_chan: |
| 200 | if close_flag == true { |
| 201 | goto run_close |
| 202 | } |
| 203 | case <-event_chan: |
| 204 | case <-tick_c: |
| 205 | } |
| 206 | |
| 207 | ev_queue.WaiterWake() |
| 208 | } |
| 209 | |
| 210 | run_close: |
| 211 | this.do_close(wait) |
| 212 | } |
| 213 |
no test coverage detected