Mercurial > prosody-hg
comparison net/server_epoll.lua @ 10984:69ed4764edda
net.server_epoll: Remove unused time field from timer objects
Unused since the move to util.indexedbheap in c8c3f2eba898
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 29 Jun 2020 20:13:12 +0200 |
| parents | 0862325842ec |
| children | 758ce12586de |
comparison
equal
deleted
inserted
replaced
| 10983:0862325842ec | 10984:69ed4764edda |
|---|---|
| 85 | 85 |
| 86 local timers = indexedbheap.create(); | 86 local timers = indexedbheap.create(); |
| 87 | 87 |
| 88 local function noop() end | 88 local function noop() end |
| 89 local function closetimer(t) | 89 local function closetimer(t) |
| 90 t[1] = 0; | 90 t[1] = noop; |
| 91 t[2] = noop; | |
| 92 timers:remove(t.id); | 91 timers:remove(t.id); |
| 93 end | 92 end |
| 94 | 93 |
| 95 local function reschedule(t, time) | 94 local function reschedule(t, time) |
| 96 time = monotonic() + time; | 95 time = monotonic() + time; |
| 97 t[1] = time; | |
| 98 timers:reprioritize(t.id, time); | 96 timers:reprioritize(t.id, time); |
| 99 end | 97 end |
| 100 | 98 |
| 101 -- Add relative timer | 99 -- Add relative timer |
| 102 local function addtimer(timeout, f, param) | 100 local function addtimer(timeout, f, param) |
| 103 local time = monotonic() + timeout; | 101 local time = monotonic() + timeout; |
| 104 local timer = { time, f, param, close = closetimer, reschedule = reschedule, id = nil }; | 102 local timer = { f, param, close = closetimer, reschedule = reschedule, id = nil }; |
| 105 timer.id = timers:insert(timer, time); | 103 timer.id = timers:insert(timer, time); |
| 106 return timer; | 104 return timer; |
| 107 end | 105 end |
| 108 | 106 |
| 109 -- Run callbacks of expired timers | 107 -- Run callbacks of expired timers |
| 119 next_delay = peek - elapsed; | 117 next_delay = peek - elapsed; |
| 120 break; | 118 break; |
| 121 end | 119 end |
| 122 | 120 |
| 123 local _, timer = timers:pop(); | 121 local _, timer = timers:pop(); |
| 124 local ok, ret = pcall(timer[2], now, timer, timer[3]); | 122 local ok, ret = pcall(timer[1], now, timer, timer[2]); |
| 125 if ok and type(ret) == "number" then | 123 if ok and type(ret) == "number" then |
| 126 local next_time = elapsed+ret; | 124 local next_time = elapsed+ret; |
| 127 timer[1] = next_time; | |
| 128 timers:insert(timer, next_time); | 125 timers:insert(timer, next_time); |
| 129 end | 126 end |
| 130 | 127 |
| 131 peek = timers:peek(); | 128 peek = timers:peek(); |
| 132 end | 129 end |
