Software /
code /
prosody
Comparison
util/async.lua @ 9177:83e7ad5818d3
util.async: Remove sleep function
Dependency on util.timer indirectly caused net.server to be initialized
before the config was read, so server_select was always chosen.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 12 Aug 2018 23:52:39 +0200 |
parent | 8995:2e6f7ab97794 |
child | 9562:acf74ad0b795 |
comparison
equal
deleted
inserted
replaced
9176:1068f9b82e2b | 9177:83e7ad5818d3 |
---|---|
1 local logger = require "util.logger"; | 1 local logger = require "util.logger"; |
2 local log = logger.init("util.async"); | 2 local log = logger.init("util.async"); |
3 local timer = require "util.timer"; | |
4 local new_id = require "util.id".short; | 3 local new_id = require "util.id".short; |
5 | 4 |
6 local function checkthread() | 5 local function checkthread() |
7 local thread, main = coroutine.running(); | 6 local thread, main = coroutine.running(); |
8 if not thread or main then | 7 if not thread or main then |
244 | 243 |
245 local function ready() | 244 local function ready() |
246 return pcall(checkthread); | 245 return pcall(checkthread); |
247 end | 246 end |
248 | 247 |
249 local function sleep(s) | |
250 local wait, done = waiter(); | |
251 timer.add_task(s, done); | |
252 wait(); | |
253 end | |
254 | |
255 return { | 248 return { |
256 ready = ready; | 249 ready = ready; |
257 waiter = waiter; | 250 waiter = waiter; |
258 guarder = guarder; | 251 guarder = guarder; |
259 runner = runner; | 252 runner = runner; |
260 sleep = sleep; | |
261 }; | 253 }; |