Commit Graph

27 Commits

Author SHA1 Message Date
bjorn 243b6ae21a Use lovrDefer more; 2024-04-01 15:32:06 -07:00
bjorn cdecc1bae7 Add defer system; Rework exceptions; util cleanup;
Defer can be used to clean up resources when an error occurs.
2024-03-29 18:10:22 -07:00
bjorn d097d9819d Add wrappers for malloc functions; 2024-03-11 14:38:00 -07:00
bjorn a4c1d9fce6 Thread module initializes job system;
Worker count can be set from conf.lua.

A negative worker count is relative to the number of cores.

-1 is the default.
2024-02-28 12:31:34 -08:00
bjorn 08d6b2ad28 Refcounted modules;
This allows them to be initialized/destroyed from multiple threads in
any order.  Previously, the first thread to require a module had to be
the last thread to use the module, otherwise it would be destroyed too
early.

There are still a few issues.  If the main thread doesn't require a
module, it won't pick up the conf.lua settings.  Also graphics isn't
handling the shader cache writing properly.  And I think this breaks the
headset-graphics refcounting.  But these will be fixed in future
commits.
2023-11-23 17:07:44 -08:00
bjorn f013831b73 Reorganize thread code;
- Put channel into thread module file.
- Make thread internals private.
- Handle more thread bookkeeping in thread module instead of Lua API.
- Fix a few race conditions/leaks nobody was probably ever going to hit.
2022-12-10 20:13:39 -08:00
bjorn e9776f98c6 Fix compatibility with Lua 5.2, 5.3, 5.4;
Part of this involved putting the Lua header back in api.h, since we
need to know the Lua version to define some macros properly.
2022-11-24 14:33:55 -08:00
bjorn 3c71828afa Revert "Change the way modules are destroyed;"
This reverts commit 019814e2c1.
2022-08-08 23:16:34 -07:00
bjorn 019814e2c1 Change the way modules are destroyed;
They are now destroyed explicitly after tearing down the Lua state
instead of relying on finalizers.  It's definitely annoying to make it
coordinated in a centralized way like this instead of being distributed,
but there's not really any reliabel way to ensure that graphics objects
are destroyed before the graphics module/device is destroyed, which is a
problem.
2022-08-04 21:44:34 -07:00
bjorn 2da18d419b mv util src; 2022-03-22 00:13:38 -07:00
bjorn e63099ba6a Flatten api.h; 2021-03-15 18:54:27 -06:00
bjorn 72284c2c5b Merge branch 'master' into dev 2021-02-12 08:16:36 -07:00
bjorn bc4cde1653 Adjust lovrRelease signature; 2021-02-08 17:52:26 -07:00
bjorn 3ded60948f rm core/ref; rm lovrAlloc; util does refcounting; 2021-02-08 17:26:44 -07:00
bjorn 0e375804fe Only include <lualib.h> when needed; 2021-02-07 16:51:31 -07:00
bjorn 3bc2c00b79 api doesn't include util; 2020-12-25 12:50:26 -07:00
bjorn e887d46256 Fix crash on non-string thread errors;
Non-string errors are currently ignored.  This is consistent with
love, and is pretty obscure, but maybe it can be improved at some point.
2020-12-11 04:41:48 -07:00
Nevyn Bengtsson 453d348fdc Stack trace when background thread crashes
Without this, the error handler only prints the _main thread's
error handler's_ stack trace
2020-11-12 18:08:05 -07:00
bjorn 1e7749a58a Fix MSVC warnings;
It's that time of year.
2020-11-12 18:08:05 -07:00
bjorn ec257b179f Support Lua 5.2, 5.3, 5.4; 2020-08-19 13:12:57 -06:00
bjorn 2a52796c6f Commenting; 2020-01-15 17:56:09 -08:00
bjorn bd6d45cd30 Add comment; 2020-01-13 23:51:59 -08:00
bjorn 056c1e7fe4 Simplify Channel cleanup; 2020-01-13 23:49:52 -08:00
mcc 2a3b4694f5 Fix crash on lovr.thread.newThread(nil) 2020-01-11 14:56:26 -05:00
bjorn c9b1f257bf api: try new file naming convention; Tupfile: cleanup;
I assume full responsibility for any catastrophes this causes.
2019-12-31 19:31:44 -08:00
bjorn e2f67c106d Thread:start supports up to 4 arguments;
They are passed to the chunk.
2019-12-13 15:50:10 -08:00
bjorn 4a47afca38 Organize api folder; 2019-05-19 00:31:42 -07:00
Renamed from src/api/types/thread.c (Browse further)