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.
4 years ago
Kim Alvefur
1e6027da6d
util.async: Clip long line [luacheck]
2 years ago
Matthew Wild
9f06132513
util.async: Expose default runner function
...
This is purely for informational purposes, so it's possible to determine
externally whether a runner is using the default runner function (which
executes functions as work items) or a custom runner function.
2 years ago
Matthew Wild
ac680a900e
util.async: Record current work item in the runner object
...
Mostly expected to be useful for debugging purposes.
2 years ago
Matthew Wild
9e43a7742a
util.async: Improve debug logging in a few places
...
Knowing the state of the coroutine as well as the runner state can be helpful.
2 years ago
Matthew Wild
ab26786924
util.async: Export a table of currently-waiting runners
...
This can be used for debugging and introspection.
2 years ago
Kim Alvefur
43531740f9
util: Prefix module imports with prosody namespace
3 years ago
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.
4 years ago
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.
4 years ago
Matthew Wild
020454b7a3
util.async: Don't attempt to close thread if not created yet
6 years ago
Matthew Wild
3c53df7847
util.async: Call coroutine.close() on dead threads (Lua 5.4)
6 years ago
Matthew Wild
9691969c44
util.async: Rename wait -> wait_for (w/compat)
...
Agreed this name is clearer and wait_for(thing) reads well in code.
6 years ago
Kim Alvefur
6b4ed1a30a
util.async: Add function for waiting on promises and unpacking the results
6 years ago
Matthew Wild
f5f6460b2e
Many things: switch from hacky multi-arg xpcall implementations to a standard util.xpcall
7 years ago
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.
7 years ago
Kim Alvefur
9c48fc4726
util.{async,timer}: Move sleep() to reduce dependencies of util.timer
8 years ago
Matthew Wild
49677384f6
MUC: Add config option to allow members to invite other members to the room (previously only owners/admins could do this)
8 years ago
Matthew Wild
bd47ba30c2
util.async: Copy hooks from main thread into coroutines
8 years ago
Kim Alvefur
e3979fdddd
util.async: Move runner id into log tag
...
Avoids string concatenation in every logger call
8 years ago
Matthew Wild
eb96155cf3
util.async: Add helper methods for setting watchers
8 years ago
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
8 years ago
Kim Alvefur
57f5ea520f
util.async: Remove last trace of async.once [luacheck]
8 years ago
Matthew Wild
072c04815b
util.async: Remove async.once(), can now be replaced by runner():run(func)
8 years ago
Matthew Wild
8a38579fa0
util.async: Make parameters to async.runner() optional
8 years ago
Kim Alvefur
1ca1c9bb32
util.async: Use wrapper for once runner (thanks luacheck)
8 years ago
Matthew Wild
e3fd2037fc
util.async: Allow nil as a guard key
8 years ago
Matthew Wild
f90a032fb6
util.async: Add sleep() method
8 years ago
Matthew Wild
38ac92b0df
util.async: Add once() to create temporary runners
8 years ago
Matthew Wild
b48a2409e7
util.async: Add ready() to check whether running in async context
8 years ago
Matthew Wild
dd23605ae8
util.async: Bump log warnings to error level
8 years ago
Matthew Wild
64594ce6f3
util.async: Split runner_continue into smaller functions for easier testing and safety
8 years ago
Matthew Wild
1490ff5472
util.async: Remove redundant line committed by mistake (Zash, luacheck)
8 years ago
Matthew Wild
2fbef935f9
util.async: ensure change in e77b37de482e applies after out-of-loop resume also
8 years ago
Matthew Wild
9d1d5d021b
util.async: Behaviour change: continue to process queued items after errors
8 years ago
Matthew Wild
8f7b5afe19
util.async: Convert asserts to a return false (same as other unexpected behaviour)
8 years ago
Matthew Wild
3059744ca4
util.async: Add comment
8 years ago
Matthew Wild
357476b690
util.async: You can never have too many asserts!
8 years ago
Matthew Wild
5c0a12d4d1
util.async: Ensure runner is left in correct state after out-of-main-loop error (+tests)
8 years ago
Matthew Wild
b62058e24a
util.async: Log the non-error state as well when there is an error being processed
8 years ago
Matthew Wild
99d071b9f8
util.async: Bugfix, don't continue main loop while there is a pending error
8 years ago
Matthew Wild
359f425e71
util.async: Fix order of statements so queue count makes more sense
8 years ago
Matthew Wild
a19c168d25
util.async: Log warning when unexpected state is reached
8 years ago
Matthew Wild
f22ee7eef6
util.async: Add per-runner ids and add runner:log() method
8 years ago
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
8 years ago
Kim Alvefur
ffc6fcf5d3
util.async: Factor out thread check into a function
8 years ago
Waqas Hussain
e31d31312f
util.async: Fix documentation URL
8 years ago
Kim Alvefur
c9778ba770
util.async: Add annotation to ignore warning [luacheck]
9 years ago
Kim Alvefur
1ab7b00c72
util.async: Rename variable to avoid name clash [luacheck]
9 years ago
Matthew Wild
e34fadb697
util.async: Add some more comments for clarity
10 years ago
Emmanuel Gil Peyrot
c6048a7cb4
Update every link to the documentation to use HTTPS
10 years ago