Kim Alvefur
43531740f9
util: Prefix module imports with prosody namespace
2023-03-17 16:23:16 +01:00
Kim Alvefur
ac06985604
util.async: Optionally allow too many 'done' callbacks
...
Sometimes, like in mod_c2s and mod_s2s during shutdown, all you want is
to wait for the first done() and not complicate things.
2022-02-22 14:17:10 +01:00
Matthew Wild
d46c43fbeb
util.async: Add next-tick configuration
...
Running woken runners in the next iteration of the event loop prevents
unexpected recursion, unexpected tracebacks, and is generally more
predictable.
The pattern is borrowed from util.promise, where we're now doing the same.
2021-11-29 14:14:30 +00:00
Matthew Wild
cfef2c6ef6
util.async: Add sleep() method with configurable scheduling backend
...
No scheduler set by default, so it will error (we plan to initialize it in
util.startup).
We wanted to avoid a hard dependency on util.timer (which in turn depends on
network backends, etc.), and we didn't add timer.sleep() because we didn't
want to add a hard dependency on util.async for things that don't need it.
2021-11-29 14:11:24 +00:00
Matthew Wild
020454b7a3
util.async: Don't attempt to close thread if not created yet
2020-06-14 09:40:08 +01:00
Matthew Wild
3c53df7847
util.async: Call coroutine.close() on dead threads (Lua 5.4)
2020-06-14 08:49:32 +01:00
Matthew Wild
9691969c44
util.async: Rename wait -> wait_for (w/compat)
...
Agreed this name is clearer and wait_for(thing) reads well in code.
2020-06-13 08:01:57 +01:00
Kim Alvefur
6b4ed1a30a
util.async: Add function for waiting on promises and unpacking the results
2019-09-29 18:42:35 +02:00
Matthew Wild
f5f6460b2e
Many things: switch from hacky multi-arg xpcall implementations to a standard util.xpcall
2018-10-26 19:32:00 +01:00
Kim Alvefur
18157ec5f8
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.
2018-08-12 23:52:39 +02:00
Kim Alvefur
9c48fc4726
util.{async,timer}: Move sleep() to reduce dependencies of util.timer
2018-07-08 00:37:01 +02:00
Matthew Wild
49677384f6
MUC: Add config option to allow members to invite other members to the room (previously only owners/admins could do this)
2018-07-06 15:33:46 +01:00
Matthew Wild
bd47ba30c2
util.async: Copy hooks from main thread into coroutines
2018-06-25 13:53:17 +01:00
Kim Alvefur
e3979fdddd
util.async: Move runner id into log tag
...
Avoids string concatenation in every logger call
2018-05-04 00:10:17 +02:00
Matthew Wild
eb96155cf3
util.async: Add helper methods for setting watchers
2018-04-30 12:53:53 +01:00
Kim Alvefur
2fa049d2e1
util.timer: Move sleep() here from util.async
...
This is to solve a indirect dependency issue where net.server was initialized before the config was read
2018-03-23 21:18:15 +01:00
Kim Alvefur
57f5ea520f
util.async: Remove last trace of async.once [luacheck]
2018-03-23 20:57:34 +01:00
Matthew Wild
072c04815b
util.async: Remove async.once(), can now be replaced by runner():run(func)
2018-03-23 14:22:01 +00:00
Matthew Wild
8a38579fa0
util.async: Make parameters to async.runner() optional
2018-03-23 14:02:33 +00:00
Kim Alvefur
1ca1c9bb32
util.async: Use wrapper for once runner (thanks luacheck)
2018-03-22 23:15:04 +01:00
Matthew Wild
e3fd2037fc
util.async: Allow nil as a guard key
2018-03-22 16:26:09 +00:00
Matthew Wild
f90a032fb6
util.async: Add sleep() method
2018-03-22 13:02:00 +00:00
Matthew Wild
38ac92b0df
util.async: Add once() to create temporary runners
2018-03-22 07:56:01 +00:00
Matthew Wild
b48a2409e7
util.async: Add ready() to check whether running in async context
2018-03-22 07:46:23 +00:00
Matthew Wild
dd23605ae8
util.async: Bump log warnings to error level
2018-03-19 11:51:40 +00:00
Matthew Wild
64594ce6f3
util.async: Split runner_continue into smaller functions for easier testing and safety
2018-03-18 12:05:38 +00:00
Matthew Wild
1490ff5472
util.async: Remove redundant line committed by mistake (Zash, luacheck)
2018-03-17 22:03:08 +00:00
Matthew Wild
2fbef935f9
util.async: ensure change in e77b37de482e applies after out-of-loop resume also
2018-03-17 17:28:07 +00:00
Matthew Wild
9d1d5d021b
util.async: Behaviour change: continue to process queued items after errors
2018-03-17 14:54:48 +00:00
Matthew Wild
8f7b5afe19
util.async: Convert asserts to a return false (same as other unexpected behaviour)
2018-03-17 11:46:21 +00:00
Matthew Wild
3059744ca4
util.async: Add comment
2018-03-16 22:31:12 +00:00
Matthew Wild
357476b690
util.async: You can never have too many asserts!
2018-03-16 22:30:25 +00:00
Matthew Wild
5c0a12d4d1
util.async: Ensure runner is left in correct state after out-of-main-loop error (+tests)
2018-03-16 22:26:15 +00:00
Matthew Wild
b62058e24a
util.async: Log the non-error state as well when there is an error being processed
2018-03-16 17:13:20 +00:00
Matthew Wild
99d071b9f8
util.async: Bugfix, don't continue main loop while there is a pending error
2018-03-16 17:12:36 +00:00
Matthew Wild
359f425e71
util.async: Fix order of statements so queue count makes more sense
2018-03-16 17:12:09 +00:00
Matthew Wild
a19c168d25
util.async: Log warning when unexpected state is reached
2018-03-16 17:11:23 +00:00
Matthew Wild
f22ee7eef6
util.async: Add per-runner ids and add runner:log() method
2018-03-16 14:59:41 +00:00
Kim Alvefur
fc8fcb69ef
util.async: Fix thread check to work correctly in Lua 5.2
...
coroutine.running() now returns the main thread and a boolean true if
called from the main thread, as opposed to nil in 5.1
2017-11-21 21:48:43 +01:00
Kim Alvefur
ffc6fcf5d3
util.async: Factor out thread check into a function
2017-11-21 21:48:14 +01:00
Waqas Hussain
e31d31312f
util.async: Fix documentation URL
2017-09-15 17:17:07 -04:00
Kim Alvefur
c9778ba770
util.async: Add annotation to ignore warning [luacheck]
2016-11-19 01:11:28 +01:00
Kim Alvefur
1ab7b00c72
util.async: Rename variable to avoid name clash [luacheck]
2016-11-19 01:11:53 +01:00
Matthew Wild
e34fadb697
util.async: Add some more comments for clarity
2016-05-22 20:06:12 +01:00
Emmanuel Gil Peyrot
c6048a7cb4
Update every link to the documentation to use HTTPS
2016-04-16 21:08:05 +01:00
Matthew Wild
7f367c1d6e
util.async: Make guarder() local
2013-08-13 23:38:50 +01:00
Matthew Wild
14f85f2f4e
util.async: Add guarder method, to create guards to ensure only a single runner can pass through a section of code at a time
2013-08-13 21:26:53 +01:00
Matthew Wild
7a082cb393
util.async: Fix logic bug that prevented error watcher being called for runners
2013-08-13 19:23:00 +01:00
Kim Alvefur
0e702abb1f
util.async: waiter: Throw error if done() called too many times
2013-08-12 13:22:27 +02:00
Matthew Wild
516179867e
util.async: waiter: Remove restriction about wait() being called before done()
2013-08-12 12:08:51 +01:00